Dynamic Data: Pulling Data from a Remote API
Enterprise Plus Feature
When setting up Dynamic Data, Enterprise Plus subscribers can elect to use an External Data Source and pull records from ANY external API directly into Logiforms to populate form fields.
When adding Dynamic Data, select "External Data Source" on the first screen:
Writing the Integration Code
Next, you'll be able to open the NodeJS Javascript Editor console. The console is based on our Webhook module and supports the same syntax to include form field values and make remote calls to external APIs like SalesForce, Asana, Zen Desk, and any other remote source. If you need a node library added, please contact your account manager, and we can install the node package that would facilitate interaction with the API.
Shown below is an actual working example of pulling data from Sales Force:
Read the syntax docs here to understand how to connect to 3rd parties.
Returning Data
When returning data, the format data is returned in is very important and must be matched exactly to avoid errors. The format is shown below.
var result = {
err:'',
noresult:'',
data:[
{
label:'Canada',
data:'CA'
},
{
label:'United States',
data:'US'
}
]
};
return result;
MultiField Population
Dynamic Data supports the concept of "MultiField Population," which means each record returned when selected on the form can also populate additional fields with related values. To return additional data for use in MultiField Population, simply add the properties and values to the objects inside the array being returned. The property name should match the Field Name exactly and IS case-sensitive. The value is the value you would like to populate the field.
Below is a full example of two records returned, which include additional values to populate the fields "Currency" and "hemisphere".
{
err:'',
noresult:'',
data:[
{
label:'Canada',
data:'CA',
hemisphere:'northern hemisphere',
currency:'CAD'
},
{
label:'United States',
data:'US',
hemisphere:'northern hemisphere',
currency:'USD'
}
]
}
0 Comments