Scenario: Get the ContactMethod Choice Text and Value on Onload of Account record.
Configured the On Load event on the Account Form and check the execution context parameter.
function onLoad(executionContext) {
let { optText, optVal } = getChoiceTextAndValue(executionContext, "preferredcontactmethodcode");
console.log("Option Set Text: " + optText);
console.log("Option Set Value: " + optVal);
}
function getChoiceTextAndValue(executionContext, optionSetFieldSchemaName) {
let optionSetText = null;
let optionSetValue = null;
if (executionContext !== undefined && executionContext !== null) {
// Get the FormContext
let formContext = executionContext.getFormContext();
// Get the Option Set Attribute
let optionSetFieldObj = formContext.getAttribute(optionSetFieldSchemaName);
// Check for the Option Set not null
if (optionSetFieldObj !== null) {
// Get the Option Set Text
optionSetText = optionSetFieldObj.getText();
// Get...