Get OptionSet Text and Value using Javascript
For MSCRM 2011/2013/2015/2016 & D365(Deprecated) -
//Get OptionSet Text
Xrm.Page.getAttribute("fieldSchemaName").getText();
//Get OptionSet Value
Xrm.Page.getAttribute("fieldSchemaName").getValue();
For D365 -
As you probably know, the Xrm.Page command usage is slowly becoming obsolete.
The execution context is an optional parameter that can be passed to a JavaScript library function through an event handler. Use the Pass execution context as first parameter option in the Handler Properties dialog while specify the name of the function to pass the event execution context.
The execution context is the first parameter passed to a function as below screenshot -
Example -
function testFn(executionContext) {
var formContext = executionContext.getFormContext();
// Get OptionSet Text
formContext.getAttribute("fieldSchemaName").getText();
// Get OptionSet Value
formContext.getAttribute("fieldSchemaName").getValue();
}
No comments:
Post a Comment