You are here:
Create Multi-Language Select Elements
Populate Select, Multi-select, and Radio elements for a multi-language Omniscript using custom configuration options.
Configure Options Manually
In Salesforce, define a set of custom labels and configure translations for them. In Omniscript designer, use the custom labels to specify the options for the Select elements.
- In Salesforce, define a set of custom labels and specify the translations for each one.
- In the Omniscript designer, add a Select element configured as follows:
For example, for a list of animals, three custom labels have translations in Salesforce.
| Custom Label | Default Value | Spanish Translation |
|---|---|---|
| Animal_Bear | Bear | Oso |
| Animal_Dog | Dog | Perro |
| Animal_Cat | Cat | Gato |
In Omniscript Designer, specify the Options for the Select element.
| Value | Label |
|---|---|
| 1 | Animal_Bear |
| 2 | Animal_Dog |
| 3 | Animal_Cat |
Populate the Options Programmatically
Create an Apex method that returns a set of options that are translated according to the language code in effect when the method is called.
For dependent Select elements that are populated programmatically (custom), configure a controlling field by specifying the name of an Omniscript element. The element has the value that determines the options in the dependent Select element. For example, a list of cities depends on a state specified in another element. For the dependent element, specify its CONTROLLING FIELD settings as follows:
- Option Source: Custom
- Source: Omit
- Element: The Omniscript element containing the value that determines how this dependent element is populated.
The Apex method must have logic that uses the value of the controlling element and the language code to determine the values to return and populate the dependent element.
- Create a class and method that returns a map of options translated according to the language code in effect when the method is called. See the sample code.
-
Add a Select element to your Omniscript, configured as follows:
- Option Source: Custom
- Source: The class and method that return the options
global class PicklistPopulation implements VlocityOpenInterface { public Boolean invokeMethod(String methodName, Map<String, Object> input, Map<String, Object> outMap, Map<String, Object> options) { try { if (methodName.equals('PopulatePicklist')) { PopulatePicklist(input, outMap, options); } else if (methodName.equals('PopulateDependentPicklist')) { PopulateDependentPicklist(input, outMap, options); } } catch (Exception e) { System.debug(LoggingLevel.ERROR, 'Exception: ' + e.getMessage() + ' ' + e.getStackTraceString()); } return true; } // Get All Contacts Associated with the ContextId Account where the Omniscript is Launched public void PopulatePicklist(Map<String, Object> input, Map<String, Object> outMap, Map<String, Object> options) { List<Map<String,String>> plOptions = new List<Map<String, String>>(); String lang = (String)input.get('LanguageCode'); for(Integer i=0; i<2; i++) { Map<String, String> tempMap = new Map<String, String>(); tempMap.put('name', 'test'+ String.valueOf(i)); // Language Independent tempMap.put('value', 'testV'+ String.valueOf(i)); // Displayed in Picklist UI if(lang == 'zh_CN') tempMap.put('value', 'testV' + String.valueOf(i) + ' 中文'); plOptions.add(tempMap); } outMap.put('options',plOptions); } // Populate a Dependent Picklist based on the Contacts ReportsToId Field Selected in the Other Field this field depends on public void PopulateDependentPicklist(Map<String, Object> input, Map<String, Object> outMap, Map<String, Object> options) { // Map of List where the Key is the Potential Values in the Other Picklist Map<String, List<Map<String, String>>> dependency = new Map<String, List<Map<String, String>>>(); String lang = (String)input.get('LanguageCode'); String elementName = (String)input.get('controllingElement'); // itself Logger.debug('hello1 ' + lang); Logger.debug('hello2 ' + elementName); List<String> controlValList = new List<String>(); controlValList.add('Licensing & Permitting'); controlValList.add('Contract'); for(Integer i=0; i<2; i++) { List<Map<String, String>> optionList = new List<Map<String, String>>(); for(Integer j=0; j<2; j++) { Map<String, String> tempMap = new Map<String, String>(); tempMap.put('name', controlValList[i] + 'Child' + String.valueOf(j)); // Language Independent tempMap.put('value', controlValList[i] + 'ChildV' + String.valueOf(j)); // Displayed in Picklist UI if(lang == 'zh_CN') tempMap.put('value', controlValList[i] + 'ChildV' + String.valueOf(j) + ' 中文' ); optionList.add(tempMap); } dependency.put(controlValList[i], optionList); } outMap.put('dependency',dependency); } }
Use a Translated Salesforce Picklist
In Salesforce, create a picklist and use Translation Workbench to define translations for it. In Omniscript designer, define a Select element that is bound to the Salesforce picklist.
-
In the Omniscript Designer, add a Select element and set these properties:
- Options Source: sObject
- Source: <sObjectName>.<fieldName>
For example, if you define a custom object named Multi_Language_Picklist and define a picklist field named Animal_Type, the syntax is
Multi_Language_Picklist__c.Animal_Type__c. - In Setup, under Administration Setup, choose Translation Workbench.
- On the Translate screen, choose the target language.
- From the Setup Component list, choose Picklist Value.
- From the Object list, choose the object where the picklist field is defined. The picklist and its values are displayed as a tree.
- For each option, specify the translated value, then save your changes.

