Answered by:
Incorrect attribute value type System.Int32

Question
-
Hi,
I have an entity with an OptionSet field. I am trying to insert a record in the entity via a Plug-in. I use an enum to represent all my option sets.
The line below throws the error "
Incorrect attribute value type System.Int32". Any ideas would be greatly appreciated.
dEntity.Attributes.Add("d_orderstatus", newOptionSetValue((int)OrderStatus.Approved));
service.Create(dEntity)
Thursday, May 31, 2012 7:31 AM
Answers
-
Hi Andreas,
This is quite bizzare. That didn't work either. The error occurs in tracing.
- Marked as answer by fifo123 Sunday, June 3, 2012 6:32 PM
Friday, June 1, 2012 7:33 AM
All replies
-
Hi,
Check if the sent int-value exists in the option set on the crm system - if the value doesn't equal one of the options the service can't create the data.
Greets,
Andreas
Andreas Buchinger
Microsoft Dynamics Certified Technology Specialist
MCPD: SharePoint Developer 2010Thursday, May 31, 2012 8:00 AM -
I did and the value exists in the option set on the crm system. Still no luck.Thursday, May 31, 2012 3:04 PM
-
Hi,
I tried the code above on my test system and it works fine...
Have you tried to call the method with the enum value itself ( dEntity.Attributes.Add("d_orderstatus", new OptionSetValue(1) )? Does the error occure in code or on the crm server in tracing?
Greets,
Andreas
Andreas Buchinger
Microsoft Dynamics Certified Technology Specialist
MCPD: SharePoint Developer 2010Thursday, May 31, 2012 3:16 PM -
Hi Andreas,
This is quite bizzare. That didn't work either. The error occurs in tracing.
- Marked as answer by fifo123 Sunday, June 3, 2012 6:32 PM
Friday, June 1, 2012 7:33 AM -
Hi,
That's really quite bizzare!
Another point that could cause the problem: Are you sure that your customizations are all published? The code in the plugin can only interact with published customizations...
Greets,
Andreas
Andreas Buchinger
Microsoft Dynamics Certified Technology Specialist
MCPD: SharePoint Developer 2010- Proposed as answer by Andreas Buchinger Monday, June 4, 2012 7:24 AM
Friday, June 1, 2012 11:08 AM -
Andreas,
I dropped and re-created the entity and it works now. Not sure why it didn't in the first place...just glad it's working. Thanks for all the help.
Sunday, June 3, 2012 6:31 PM -
Hi,
I'm glad that it works now - it would be nice if you also mark one of mine hints as possible answer...
Thanks and Greets,
Andreas
Andreas Buchinger
Microsoft Dynamics Certified Technology Specialist
MCPD: SharePoint Developer 2010Monday, June 4, 2012 7:22 AM