Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This function retrieves a dictionary of possible values localised to the current user. Taken from: <a href="http://woodsworkblog.wordpress.com/2012/11/10/crm-2011-programatically-finding-the-values-of-picklists-optionsets-statecode-statuscode-and-boolean-two-options/" rel="noreferrer">CRM 2011 Programatically Finding the Values of Picklists, Optionsets, Statecode, Statuscode and Boolean (Two Options)</a>.</p> <pre class="lang-cs prettyprint-override"><code>static Dictionary&lt;String, int&gt; GetNumericValues(IOrganizationService service, String entity, String attribute) { RetrieveAttributeRequest request = new RetrieveAttributeRequest { EntityLogicalName = entity, LogicalName = attribute, RetrieveAsIfPublished = true }; RetrieveAttributeResponse response = (RetrieveAttributeResponse)service.Execute(request); switch (response.AttributeMetadata.AttributeType) { case AttributeTypeCode.Picklist: case AttributeTypeCode.State: case AttributeTypeCode.Status: return ((EnumAttributeMetadata)response.AttributeMetadata).OptionSet.Options .ToDictionary(key =&gt; key.Label.UserLocalizedLabel.Label, option =&gt; option.Value.Value); case AttributeTypeCode.Boolean: Dictionary&lt;String, int&gt; values = new Dictionary&lt;String, int&gt;(); BooleanOptionSetMetadata metaData = ((BooleanAttributeMetadata)response.AttributeMetadata).OptionSet; values[metaData.TrueOption.Label.UserLocalizedLabel.Label] = metaData.TrueOption.Value.Value; values[metaData.FalseOption.Label.UserLocalizedLabel.Label] = metaData.FalseOption.Value.Value; return values; default: throw new ArgumentOutOfRangeException(); } } </code></pre> <p>So you would then need to do something like:</p> <pre class="lang-cs prettyprint-override"><code>Dictionary&lt;String, int&gt; values = GetNumericValues(proxy, "your_entity", "new_producttypesubcode"); if(values.ContainsKey("Trophy")) { //Do something with the value OptionSetValue optionSetValue = values["Trophy"]; int value = optionSetValue.Value; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload