Skip to main content

Creating Metadata Components

Use this article to understand how to create and edit metadata components in Swantide's Workflow builder to create your reusable Workflow assets.

Engineering Swantide avatar
Written by Engineering Swantide
Updated this week

Metadata components are the foundation of a Swantide workflow. They define which Salesforce metadata is created or updated when the workflow is deployed. Whatever solution or reusable asset you are building, the associated metadata (objects, fields, flows, etc.) is brought in as metadata components.

You can add as many components as needed in a single workflow.


Adding Metadata Components

To start adding metadata components, select the "+ Add Metadata Component" button within Workflow builder

The Metadata Component Editor Overview

In this create metadata components window, you'll see the following options:

1. JSON Editor

Once in the metadata component section, you will bring in a single component's metadata into the JSON editor. This is where metadata is displayed and edited. Metadata is represented in Salesforce’s Metadata API JSON format.


2. Load Existing Metadata

Using the "Load Existing Metadata" button is the easiest way to pull in metadata to the JSON editor, opposed to manually creating the metadata. When using the Load Existing Metadata button, you will fill out the following inputs:

  1. Select the source org you'd like to pull in metadata from, you will have the option to select any of your connected child orgs to choose from

  2. Choose the metadata type (e.g., CustomObject, CustomField, WorkflowRule, etc.)

  3. In the “Choose an Object” section, search for the full API name of the component as it is in Salesforce to pull in the specific metadata component

Manual Editing: Once loaded, you can adjust or add to the JSON directly. This is also where you’ll define variable aliases in the metadata if your workflow uses variable inputs.

Tip: For any question on metadata types and naming conventions, consult the Salesforce Metadata API documentation or a quick google


3. Sync Metadata

Metadata in your Salesforce is automatically synced and updated nightly in Swantide, if you’ve recently made changes in Salesforce and need them before the nightly sync, use Sync Metadata to pull the latest version of a component.


4. Deploy Rules

Deploy rules define how metadata is treated during deployment:

  • API_POST: Creates new metadata in Salesforce.

  • API_PATCH: Updates existing metadata in Salesforce.

    • ⚠️ Important: When updating, only include the fields you want to change in the JSON. If you leave in other metadata lines, those fields will also be updated in Salesforce.

    • Example: If you only want to update sharing rules on an object, include only the object’s fullName and the sharingRules section.

  • BUNDLED_DEPLOY: Rarely used. This is for cases where multiple components must be deployed simultaneously. If you think you may need this, contact Swantide Support.


5. Additional Fields

  • Choose a key to define a new metadata subsection: Advanced feature, not typically needed. Contact Swantide Support if required.

  • Component Type: Automatically populated when loading metadata. If writing JSON manually, set this to the correct Salesforce metadata type (e.g., CustomObject, CustomField).


Examples:

Creating a New Field metadata components

Updating Existing Object metadata component

Best Practices & Gotchas

  1. Only Bring in What you Need: When updating existing metadata using the API_PATCH deploy rule, you should only include the parts of the metadata you intend to change. Any metadata you bring into the JSON editor will be updated in Salesforce when the workflow is deployed.

    Example:
    If you’re updating only an object’s sharing rules, keep just:

    • the fullName (you will always need the first line of the JSON with the fullName to identify the object's unique name)

    • the sharingRules section you are modifying


    Remove all other metadata lines. If you leave in other metadata lines (like field definitions or layout settings), those will also be overwritten in Salesforce, since they are defined in the metadata component

  2. Respect Deployment Order: metadata components are deployed in the order they appear in Workflow builder. For example, if a workflow contains metadata components for a new object, fields, and a flow that references the new object/fields, they should be arranged in that order. You can always reorder the metadata components in workflow builder after creating them.

Did this answer your question?