Hi,
Today I got a requirement to write JavaScript code to get text of the option set value and perform some business validations.
Its really pretty simple to get the option set text from the particular entity and attribute.
We just need to add SDK.Metadata.js reference. This can found under (SDK\SampleCode\JS\SOAPForJScript\SOAPForJScript\Scripts) and use the below code.
function (result) {
for (var i = 0; i < result.OptionSet.Options.length; i++) {
var text = result.OptionSet.Options[i].Label.LocalizedLabels[0].Label;
var value = result.OptionSet.Options[i].Value;
}
},
function (error) { }
);
}
Hope this helps.
--
Happy CRM'ing
Gopinath
Today I got a requirement to write JavaScript code to get text of the option set value and perform some business validations.
Its really pretty simple to get the option set text from the particular entity and attribute.
We just need to add SDK.Metadata.js reference. This can found under (SDK\SampleCode\JS\SOAPForJScript\SOAPForJScript\Scripts) and use the below code.
function GetOptionSetText(EntityLogicalName, AttributeLogicalName)
{
SDK.Metadata.RetrieveAttribute(EntityLogicalName,
AttributeLogicalName, "00000000-0000-0000-0000-000000000000", true,function (result) {
for (var i = 0; i < result.OptionSet.Options.length; i++) {
var text = result.OptionSet.Options[i].Label.LocalizedLabels[0].Label;
var value = result.OptionSet.Options[i].Value;
}
},
function (error) { }
);
}
Hope this helps.
--
Happy CRM'ing
Gopinath
No comments:
Post a Comment