![](https://arunpotti.files.wordpress.com/2023/07/image.png?w=838)
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.
![](https://arunpotti.files.wordpress.com/2023/07/image-24.png?w=838)
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
![](https://i0.wp.com/365community.online/wp-content/uploads/nsl_avatars/a2e17abf95b0195b8693d17f58f418f1.png?fit=96%2C96&ssl=1)
Array
Dyn365CE26 July 2024API playground feature not available in Dataverse Accelerator App?
Dyn365CE25 July 2024How to Explore and test Dataverse in the Web API playground (preview)?
Dyn365CE20 July 2024Web resource method does not exist in Dynamics 365 CE
Dyn365CE19 July 2024How to get Environment Variable Value in Dynamics 365 CE using JavaScript?