We have created web services that provide the values of the custom option sets in our Lead entity. These are called into dropdownlists on an asp.net web form;
WebSvc.WcfSvcClient enq_wsvc = new WebSvc.WcfSvcClient();
Dictionary<Int64, string> genderData = new Dictionary<Int64, string>();
genderData = enq_wsvc.GetGender();
genderDropDown.DataSource = genderData.Values;
genderDropDown.DataBind();
genderDropDown.Items.Insert(0, new ListItem("", "-1"));
We then pass this back via on the button click event;
newLead.gender = genderDropDown.SelectedItem.Text;
enq_wsvc. SetLead(newLead);
Using the OperationContract / DataContract method;
[DataMember]
public string gender
{
get { return genderDropDown; }
set { genderDropDown = value; }
}
To then finally have the CRM web service create the new record;
lead["uoc_gender"] = newLead.gender.ToString();
Guid newLeadId = myCRMService.Create(lead);
This works for all the ‘Single Line of Text’ formatted fields on the form, but does not work this option set, giving me the following error;
Incorrect attribute value type System.String
I can step through the code and see the values being brought over prior to the .Create(lead) so I’m stumped. I haven’t been able to find any guidance on how to do this via dropdownlists/webservices despite a lot of looking and failed testing.
Am I right in thinking that is because I’m trying to update an option set field, and if so how does this differ from trying to update a standard text field?
Any help massively appreciated. Thanks