Salesforce Picklist Options
Syncing dropdown field options with the picklist values of a Salesforce object's properties

Step 1:
Create a dropdown field with no options and is disabled by default
Navigate to your form's designer
Add a new dropdown field and give it an id.
Set its properties to Readonly, and remove the default options it has.

Step 2:
Create an API Connector that fetches the Salesforce object
Navigate to the logic page for your form.
Under the "API Connectors" tab, press Create API Connector
Choose "Custom Connector" and hit Next
Fill out the API Connector to correspond with your needs.
Use this url, but fill in your Salesforce instance url and object name: https://<YOUR_SALESFORCE_URL>/services/data/v50.0/sobjects/<YOUR_SALESFORCE_OBJECT>/describe
Add a "Authorization" header with the value "Bearer {{salesforce_token}}"
This will prompt you to choose a connected Salesforce Account to use
Hit Next and Skip

Step 3:
Create a Logic rule that uses the API Connector to set a field's options
Under the "Rules" tab, press Create Rule
Set the Trigger to "Form Step is Loaded" and choose the step to run the rule on
Switch the rule to Advanced Logic and press edit code
Paste this code in and change
Industry
to the Salesforce Object field name you want, andsf_industry_dropdown
to the Field ID of your dropdown field.
function setPicklistOptions(sf_fields, sf_field_name, feathery_field_name) {
const sf_field = sf_fields.find(field => field.name === sf_field_name);
if (!sf_field) {
throw new Error("Could not find the Salesforce field!")
}
const picklist_values = sf_field.picklistValues;
const options = picklist_values.map(option => option.value)
feathery.fields[feathery_field_name].options = options;
feathery.fields[feathery_field_name].disabled = false;
}
try {
const response = await feathery.http.connect("Salesforce Describe Object");
const fields = response.data.fields;
setPicklistOptions(fields, "Industry", "sf_industry_dropdown");
// Call setPicklistOptions() for more fields here
} catch (error) {
console.log(error.message)
}
Result:
Now the dropdown options are pulled from Salesforce automatically, when the step is loaded.

Last updated
Was this helpful?