Skip to main content

The Select element in Omniscript allows you to create a dropdown list or picklist, enabling you to choose a single option from the available options.

There are three ways to set the options for the Select dropdown:

    1. Manual: Manually enter the options using label/value pairs.
    2. SObject: Retrieve the options from a Salesforce object and field.
    3. Custom: Fetch the options from an Apex controller.

In this blog, we will explore how to dynamically populate the Select element by retrieving values from an Apex class.

let’s create an Apex class named “GetPicklistValueByAccount.” In this class, we will retrieve the account records and provide the Name and Id of each account in a label/value format, which can be utilized by the Select element in Omniscript.

Please add the code provided below to your Apex controller and save it:

global class GetPicklistValueByAccount implements omnistudio.VlocityOpenInterface {
    public Boolean invokeMethod(String methodName, Map<String, Object> input, Map<String, Object> outMap, Map<String, Object> options) {
        if (methodName.equals('PopulateAccountPicklistValue')) {
            PopulateAccountPicklistValue(input, outMap, options);
        return true;
    public void PopulateAccountPicklistValue(Map<String, Object> input, Map<String, Object> outMap, Map<String, Object> options) {
        List<Map<String, String>> accList = new List<Map<String, String>>();
        for (Account acc : [SELECT Name, Id FROM Account LIMIT 10]) {
            Map<String, String> accMap = new Map<String, String>();
            accMap.put('name', acc.Id);
            accMap.put('value', acc.Name);
        outMap.put('options', accList);

To add a Select element to a Step in Omniscript and choose Custom as the Option Source, follow these steps:

    1. Drag and drop a Select element onto the desired Step in Omniscript.
    2. Select Custom as the Option Source for the Select element.
    3. In the Source property, enter the name of the method to be called on a class, following the format class.method. In this example, it would be GetPicklistValueByAccount.PopulateAccountPicklistValue.
Select element to a Step in Omniscript

In the provided code, it’s important to note that “omnistudio” represents the Namespace prefix of the vlocity package. Please keep in mind that this prefix may vary from one organization to another. To determine the namespace prefix for your org, you can navigate to Quick Find and select “Installed Packages.”

The “invokeMethod” function is automatically triggered from the Omniscript. By utilizing the “methodName” parameter, we can specify the method to be called, which corresponds to the Source property of the Select element.

In the code, “Map<String, Object> input” retrieves all the data from the Omniscript, while “Map<String, Object> outMap” sends the output from the Apex controller back to the Omniscript.

The method name “PopulateAccountPicklistValue” is the designated name that will be invoked when the Omniscript is rendered.

Populate Account Picklist Value

Thank you!! I hope this information is helpful for you.


Subscribe For More Updates


Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!