Notifications
Announcements
No record found.
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
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
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
Check if you can find the label value under the 'FormattedValues' of the PreImages.
Let me know if you need more details.
gCRStatus = PostImg.Contains("mms_gcrstatus") ? PostImg.FormattedValues["mms_gcrstatus"] : string.Empty;
this worked thank you.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
SA-08121319-0 4
Calum MacFarlane 4
Alex Fun Wei Jie 2