Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

How to tell programmatically if a field is bound to an optionset

$
0
0

I'm doing some Dynamics CRM development.  I've encountered code that looks like this:

Entity entity = new Entity("xxx");
foreach (InBoundDynamicsApiCall.FieldNameValuePair nameValuePair in InquiryNameValuePairs)
{
    entity[nameValuePair.FieldName] = nameValuePair.FieldValue;
}

orgService.Create(inquiryToCreate);

Using this code, I am able to add entities to Dynamics CRM.  Please note that I did not write the above code and I don't know if I can change it.

However, there is a problem.  Some fields in the xxx entity are bound to optionsets.  I was previously told on this forum to use this form: inquiryToCreate["attributename"]=new OptionSetValue(101);

That's great, but it leaves an issue.  The code I introduced above doesn't know which fields are bound to optionsets, so I was wondering if I could modify the above code so that it knows which fields use optionsets.


Viewing all articles
Browse latest Browse all 79901

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>