Asked by:
SQL SSIS - CRM 2011 integration - failed insert option set

Question
-
Hi, i'm a new CRM technical & i want to ask something. Here i have a task to create integration for SQL - CRM Dynamic 2011. I using this tutorial(http://a33ik.blogspot.com/2012/02/integrating-crm-2011-using-sql.html), and i have a problem when i want to insert an option set type field(like gender, family status code).
I also tried some code but all of this was failed :
---> new_contact["gendercode"] = new OptionSetValue(1); ---> error because the reference cannot use .NET 4 framework
---> new_contact["gendercode"] = new OptionSetValue().Value = 2; ---> and it give me error "Incorrect attribute value type System.Int32"
---> new_contact["gendercode"] = new OptionSetValue(){Value = 2}; ---> this give me error "There was an error while trying to serialize parameter http://schemas.microsoft.com/xrm/2011/Contracts/Services:entity. The InnerException message was 'Type 'CRM_Proxy.CRM.OptionSetValue' with data contract name 'OptionSetValue:http://schemas.microsoft.com/xrm/2011/Contracts' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'"
I tried to search it in google and still not find a solution. Any help would be appreciated :)
Thanks & Regards,
EDK CRM
Thursday, September 12, 2013 6:50 AM
All replies
-
Hi,
Try following example:
OptionSetValue myOptionSet = new OptionSetValue();
myOptionSet.Value = xxxx
new_contact["gendercode"]= myOptionSet;
Hope this helps.
-----------------------------------------------------------------------
Minal Dahiya
If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"- Proposed as answer by Minal Dahiya Thursday, September 12, 2013 7:45 AM
Thursday, September 12, 2013 7:45 AM -
Hi Minal,
Thanks for your response, I have tried that before and it doesn't work. It give the same error like the point 3 in my 1st post.
From the error message, is it have something to do with the service reference created from my CRM server organization.wsdl?
Thanks & Regards, EDK
Thursday, September 12, 2013 8:10 AM -
Hi
Did you got soultion for this ? I am also facing same problem.
Saturday, September 28, 2013 4:25 AM -
Hi Atul Bhagat,
Well, i also didn't find the solution about this case. And then i decide to use web service to insert and update the record with schedule time.
When using web service it easily to use this code ---> new_contact["fieldname"] = new OptionSetValue(1);
Thanks & Regards, EDK
Saturday, September 28, 2013 5:31 AM