Executing a Function from a Salesforce Flow

Updated 1 week ago by Copado Solutions

Copado allows you to execute a function from multiple places. In this article, you will learn how to execute a function from a flow.

If you want to execute a function as part of your Salesforce flow, you can easily do this using the Invoke Copado Function Apex action. You need to provide the functions’ API name and the required parameters, if any. You can find this information in the Function record:

Apex Action

If your function requires additional parameters, you can specify them in the Parameters (JSON) input field. Simply enter a json array with the list of parameters and their values. For example:

[{"name":"example-name","value":"example.value"}, {"name":"example-name2","value":"example.value2"}]

Parameters JSON field

If you need to reference a parameter you have defined in the flow, you can use the Parameters field. Additionally, if you want to reference a set of parameters you have defined in a JSON field outside the flow, you can use the Parameters (JSON) field. If you provide a value for both fields, Copado will apply the values in the Parameters (JSON) field.

If the parameter values depend on a variable from the Salesforce flow, you can also create a flow resource of type Formula and enter a value like this:

[{"name":"example-name","value":"example.value"}, {"name":"currentDate","value":"{!$Flow.CurrentDate}"}]

Then, simply select the formula resource as the variable in the ParametersJSON field of the Invoke Copado Function Apex action.

If you want to use the result status component in a screen flow to see the progress when you execute a function, you can configure it as follows:

Component: resultStatusMonitor

Variables: 3 input variables:

  • recordId: 
    • Resource Type: Variable
    • Data Type: Text
    • Id of the Result record returned after executing the function.
  • objectAPIName
    • Resource Type: Variable
    • Data Type: Text
    • Currently, this option is only available for the Result object (copado__Result__c).
  • showDetailLink
    • Resource Type: Variable
    • Data Type: Boolean
    • If you want to display a link to the Result record, set this variable to {!$GlobalConstant.True}. Otherwise, set it to false.

resultStatusMonitor component
If you are on the latest version of Copado, this component has been replaced by the new Result Status Container. This new component is not yet available to be added to a flow and will become available in the next release.

How did we do?