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.