Loading
Prepare for Email to Become the Default Login ExperienceRead More
Populating Picklist Values in Omniscript Inputs from Apex

Populating Picklist Values in Omniscript Inputs from Apex

You can populate Select, Multi-select, and Radio elements from a Callable Apex class. The values for the element are obtained during the Omniscript's activation.

To populate a picklist from an Apex class, make sure to enable Get picklist values when the Omniscript loads for the Omniscript from Setup. For the designer on a managed package, enable Fetch Picklist Values at Script Load.

To populate the options of an element, a List<Map<String, String>> is returned from the Apex class. The Map Options are Name, the Language Independent Option, and Value, the UI Display value.

Sample Apex Code for Populating a Picklist:

global with sharing class SelectOptionsCallable implements Callable
{
   global Object call(String action, Map<String, Object> args)
   {
       switch on action {
           when 'SelectOptions' {
               return SelectOptions((Map<String, Object>)args.get('input'), (Map<String, Object>)args.get('output'));
           }
       }
       return null;
    }
   
    private List<Map<String, Object>> SelectOptions(Map<String, Object> inputMap, Map<String, Object> outMap)
    {
        List<Map<String, Object>> optionList = new List<Map<String, Object>>();
        for (Account acc : [ Select Id, Name from Account limit 8])
        {
             Map<String, Object> option = new Map<String, Object>();
             option.put('name', acc.Id);
             option.put('value', acc.Name);
             optionList.add(option);
        }
        
        outMap.put('options', optionList);
                
        return optionList;
    }
}

For information on populating dependent picklists, see Populating Dependent Picklist Values in Omniscript Inputs with Apex.

 
Loading
Salesforce Help | Article