There might arise conditions where you want your end customers to select in the config from a list by using the Select field type, like List of Stages or List of Vendors which are platform specific.

If a list option is not available to add in Select, you can do so by using DataSource using which you fetch the fields from another workflow in a name-value pair format.

The users can then select from the options defined for the field which is fetched from the platform in real time.

Refer to this video to get a brief overview about Data Source.

Creating Select field using DataSource

Let’s consider an example of Quickbooks where you want your user to select the Vendor name and then use that Vendor ID in a workflow.

For this, you simply need to create a workflow which fetches all the Vendors from QuickBooks and then displays them as a name value pair to the user during runtime where the name will be the display name of the Vendor and the value will be its Vendor ID.

Step 1: Setup of Data Source Config Field

1

Create Select Field Config

Navigate to the QuickBooks integration in Cobalt and go to Config Portal. Click on + Add Field, provide a name and choose the type as Select. Click on Add Field.

2

Use DataSource in Select Field

Click on Edit button for the field you just created and check the Use Data Source checkbox.

You will notice that you are now asked to select a workflow to get the options from.

Let’s create the workflow to get Vendors list.

Step 2: Create the Data Source workflow

1

Create Workflow for Data Source

In QuickBooks, add a new workflow and name is as Get Vendors (DataSource) so that it is easy to identify.

2

Get Vendors from QuickBooks

Connect a QuickBooks node to the Start Node in the workflow and either use the action to get list of vendors or configure the API using the HTTP Request action.

As the workflow will be used as Data Source, no trigger needs to be added to the Start Node of the workflow.

3

Convert Vendor data into a Key Value pair

Once you have fetched all the vendor data, you now need to convert that in a name value pair where the name is usually a display name for the end users so that it is easier for them to select option, while the value is the ID of the vendor or any other field that you want to use in your workflow.

We can do this either by Transform Node or Custom Code node.

4

Transform Node to convert data in required format

Connect a Transform node to QuickBooks and based on the response received, we map fields into a name value pair.

This is a sample code we used to perform mapping.

Transform Query
{
"vendors":  $map(records, function($k){    
{     
    "name": $k.DisplayName,
    "value": $k.Id       
    }
    })
}

Ensure that you do mapping only as name and value pair, otherwise the options will not work correctly.

5

Send transformed data in Response node

As a final step of every DataSource workflow, you need to send that data in a Response node so that it’s visible to your users as options in Config.

Ensure that no other node is connected after Response node and it is the last node of the workflow.

Connect a Response node and add the response received from transform node here in the Data field.

This is just a simple workflow to create options for users in the config. You can create workflows as per your requirement and simply send them as options in the Response node at the end.

Step 3: Publish Workflow and add to Config

Once the workflow is completed, Publish it for your users.

If the Data Source workflow is not published, it will not execute for your users and not display any options.

Now go back to the Config Portal and in the field, select the workflow that you created and click on Save.

You have now successfully created a config using DataSource.