Hear from Salesforce leaders on how to create and deploy Agentforce agents.
Contact Us 1-800-596-4880

Propagate Metadata to Other Flows

Studio enables you to propagate metadata in your source flow to other, target flows referenced within your application. Depending on metadata already in the target flow, you might need to configure the specific metadata to propagate from the source flow.

Propagate Metadata to a Flow Without Custom Metadata

When you add a Flow Reference component to your source flow and reference a target flow with no custom metadata configured, Studio automatically propagates the metadata in your source flow as custom metadata in your target flow.

  1. In the taskbar at the top of the Anypoint Studio display, select File > New > Mule Project.

  2. Type a name for your new project and select Finish.

  3. Drag two flow components to your empty canvas and name them flow-1 and flow-2:

    both flows metadata
  4. Drag a Set Payload component to flow-1 and configure the payload:

    {
      "value": {
        "ID": 1,
        "departureDate": "2016/12/20",
        "emptySeats": 200,
        "plane": {
          "type": "Boeing 747",
          "totalSeats": 400
        }
      }
    }
    JSON
    set payload config
  5. Drag a Logger component to flow-2 and configure it to log payload:

    logger payload metadata
  6. Drag a Flow Reference component to the end of flow-1 and configure it to reference `flow-2`:

    flow reference metadata
  7. Note that the metadata tab in flow-2 is now populated with autogenerated metadata, and the input tab in the metadata explorer reflects the payload format that the Set Payload component determines in flow-1:

    logger metadata case 1

Propagate Metadata When Extracting an Operation From Your Flow to a New Flow

When you extract an operation from your source flow to propagate to a new target flow or subflow, Studio enables you to configure the metadata that you want to propagate to the newly created flow:

  1. In the taskbar at the top of the Anypoint Studio display, select File > New > Mule Project.

  2. Type a name for your new project and select Finish.

  3. Drag a flow component to your empty canvas and name it flow-1.

  4. Drag a Set Payload component to flow-1 and configure the payload:

    {
      "value": {
        "ID": 1,
        "departureDate": "2016/12/20",
        "emptySeats": 200,
        "plane": {
          "type": "Boeing 747",
          "totalSeats": 400
        }
      }
    }
    JSON
    set payload flow 1
  5. Drag a Logger component to the end of flow-1 and configure it to log #[payload.value.departureDate]:

    logger metadata case 2
  6. Right-click your Logger component and select Extract To…​ > Flow:

    extract operation metadata
  7. Name your target flow flow-2.

  8. Select Metadata Preferences to configure the input and output metadata.
    Note that Studio automatically recognizes the metadata of your flow.

    extract flow metadata
  9. Select OK.

  10. Your Logger component is now in flow-2, the metadata tab is populated with autogenerated metadata, and the input tab in the metadata explorer reflects the payload format that the Set Payload component configures in flow-1:

    extract flow metadata final

Propagate Metadata to a Flow with Custom Metadata Already Configured

When you add a Flow Reference component to your source flow and reference another, target flow that has custom metadata already configured, Studio prompts you to select the metadata that you want to propagate:

  1. In the taskbar at the top of the Anypoint Studio display, select File > New > Mule Project.

  2. Type a name for your new project and select Finish.

  3. Drag two flow components to your empty canvas and name them flow-1 and flow-2:

    both flows metadata
  4. Drag a Set Payload component to flow-1 and configure the payload:

    {
      "value": {
        "ID": 1,
        "departureDate": "2016/12/20",
        "emptySeats": 200,
        "plane": {
          "type": "Boeing 747",
          "totalSeats": 400
        }
      }
    }
    JSON
    set payload config
  5. Create a JSON file with the name `arrival-type-example.json` in your src/main/resources/examples directory with the following format:

    arrival-type-example.json
    {
      "value": {
        "ID": 1,
        "arrivalDate": "2016/12/20",
        "plane": {
          "type": "Boeing 747",
          "totalSeats": 400
        }
      }
    }
    JSON
  6. Select flow-2 > Metadata tab > Add Metadata:

    add metadata flow 2
  7. Select Input: Payload > Edit:

    configure input metadata
  8. Select Add, create a new metadata type called `arrivalType`, and select Create type:

    create metadata type
  9. Select the type JSON > Example and select the …​ button to browse to src/main/resources/examples/arrival-type-example.json:

    create json metadata type
  10. Click Select.

  11. Drag a Logger component to flow-2 and configure it to log payload:

    logger payload metadata
  12. Drag a Flow Reference component to the end of flow-1 and configure it to reference `flow-2`:

    flow reference metadata
  13. Select the Flow Reference component Metadata tab, and select Set Metadata:

    set metadata example

    Studio warns you that setting the metadata from flow-1 will overwrite the existing arrivalType metadata type configured for flow-2:

    overwrite metadata
  14. Select Customize to configure the desired metadata to propagate to the flow.

    Note that Studio recognizes the actual metadata as that set in flow-1, and the expected metadata as that configured in flow-2.

    custom metadata configure overwrite

    Customizing the actual and expected metadata for a referenced flow is helpful if you want to define a specific set of metadata to propagate.