Asked by:
how to get statuscode description?

Question
-
Hello, I've defined some custom statuscodes for my incident entity. When I set a breakpoint, I get the new statuscode, as expected. However, I need to get the option text description for the status code.
So say I've defined "Repro"/5 as a Resolved status code option. In my plugin code, I set a breakpoint and get incident.StatusCode of 5 as expected. What's the easiest way for me to get the StatusCode description of "Repro" for that specific statuscode, at that point?Thursday, November 14, 2013 12:37 AM
All replies
-
Hello,
Please re-check following thread.
Hope this helps. If you get answer of your question, please mark the response as an answer and vote as helpful !
Vikram !Thursday, November 14, 2013 1:58 AM -
Here is a good example - https://community.dynamics.com/crm/b/c5insightblog/archive/2011/03/04/dynamics-crm-2011-reading-attribute-values-inside-your-plug-in.aspx
Blake Scarlavai - http://mscrmdev.blogspot.com/ - Sonoma Partners - http://www.sonomapartners.com/ - Follow @bscarlav
CRM 2011 JavaScript Model Generator - CRM 2011 Appender for log4netThursday, November 14, 2013 3:01 AM -
Hello
I tried to get the Text values of PickList using both the above methods and both worked for me:
1. using Retrieve method, i created a method for this (took help of one internet link). Paste this method and call it with input parameters to get the string value of picklist.
private string GetOptionsSetTextOnValue(IOrganizationService service, string entityName, string attributeName, int selectedValue) { try { RetrieveAttributeRequest retrieveAttributeRequest = new RetrieveAttributeRequest { EntityLogicalName = entityName, LogicalName = attributeName, RetrieveAsIfPublished = true }; RetrieveAttributeResponse retrieveAttributeResponse = (RetrieveAttributeResponse)service.Execute(retrieveAttributeRequest); PicklistAttributeMetadata retrievedPicklistAttributeMetadata = (PicklistAttributeMetadata) retrieveAttributeResponse.AttributeMetadata; OptionMetadata [] optionList = retrievedPicklistAttributeMetadata.OptionSet.Options.ToArray(); string selectedOptionLabel = string .Empty; foreach (OptionMetadata oMD in optionList) { if (oMD.Value == selectedValue) { selectedOptionLabel = oMD.Label.UserLocalizedLabel.Label; break; } } return selectedOptionLabel; } catch (System.ServiceModel.FaultException ex1) { string strEr = ex1.InnerException.Data.ToString(); return null; } }
2. Using LinQ:
using System.Linq; // add this namespace using (OrganizationServiceContext orgSvcContext = new OrganizationServiceContext (service)) { var query1 = from c in orgSvcContext.CreateQuery<ENTITY_NAME>() where c["crm attribute1 in lower case"].Equals("value in string") && c["crm attribute2 in lower case"].Equals("value in string") && c["crm attribute3 in lower case"].Equals("value in string") select new { picklistStringValue = c.FormattedValues["picklist crm attribtue in lower case"] // formattedValues to get label string name } ; foreach (var q in query1) { string strPicklistStringValue = q.picklistStringValue.ToString(); break; } }
Thursday, November 14, 2013 8:12 AM -
you can check different optionset values available in a particular entity running the below SQL.
SELECT * FROM FilteredStringMap WHERE FilteredViewName='FilteredIncident'
Friday, November 15, 2013 3:20 PM