
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...
Source link
More About This Author

Array
Dyn365CE22 September 2023How to show the Power Automate complete Expressions?
Dyn365CE18 September 2023Dataverse Error: Cannot start the requested operation [EntityCustomization] because there is another [PublishAll] running at this moment.
Dyn365CE13 September 2023Power Automate Error: You should specify a contact or account.
Dyn365CE13 September 2023How to Download Dynamics CE Developer Tools using Power Platform Tools in Visual Studio Code?