I am able to get the value from the preimage/post image but not the label for the option set.
preStatuscode = PreImage.GetAttributeValue<OptionSetValue>("statuscode");
*This post is locked for comments
I am able to get the value from the preimage/post image but not the label for the option set.
preStatuscode = PreImage.GetAttributeValue<OptionSetValue>("statuscode");
*This post is locked for comments
gCRStatus = PostImg.Contains("mms_gcrstatus") ? PostImg.FormattedValues["mms_gcrstatus"] : string.Empty;
this worked thank you.
Check if you can find the label value under the 'FormattedValues' of the PreImages.
Let me know if you need more details.
Hi Prasad,
use below method to get the option-set label in plugin,
public static string GetOptionSetValueLabel(string entityName, string fieldName, int optionSetValue, IOrganizationService service) { var attReq = new RetrieveAttributeRequest(); attReq.EntityLogicalName = entityName; attReq.LogicalName = fieldName; attReq.RetrieveAsIfPublished = true; var attResponse = (RetrieveAttributeResponse)service.Execute(attReq); var attMetadata = (EnumAttributeMetadata)attResponse.AttributeMetadata; return attMetadata.OptionSet.Options.Where(x => x.Value == optionSetValue).FirstOrDefault().Label.UserLocalizedLabel.Label; }
Also you can refer
https://community.dynamics.com/crm/b/mshelp/archive/2012/06/12/get-optionset-text-from-value-or-value-from-text
Best Regards,
Shahbaaz
Hi,
you need access the metadata in order to get the label. You can refer below post to get the code.
stackoverflow.com/.../get-the-string-value-from-optionsetvalue-in-crm-plugin
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,269 Super User 2024 Season 2
Martin Dráb 230,198 Most Valuable Professional
nmaenpaa 101,156