Answered by:
Set state using JScript/oData for custom entity

Question
-
Hello All,
I need to deactivate some instances of entities retrieved using an oData/JScript query.
I know that the statecode/statuscode need to be updated (to values of 1 and 2 respectively).
I've tried just using a oData/JScript call, but I get an error telling me that "2 is not a valid value for status code" (paraphrased).
I see that there are some SetStateXxxxx functions available for the "Execute" method that can be called. Here is a link: http://msdn.microsoft.com/en-us/library/cc677072.aspx
But, these seem to imply that they only work on built-in entities. How do I get this to work with a custom entity?
Thursday, March 8, 2012 10:10 PM
Answers
-
You can't set the state of an entity in odata/rest end points. You need to use soap to do that.
It workd for both inbuilt and custom entities
here are the samples
http://dotnetdevlife.blogspot.com.au/2011/06/crm-2011-setting-state-from-jscript.html
http://mileyja.blogspot.com.au/2011/07/set-status-or-state-of-record-using.html
i hope this helps.
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Amreek Singh Senior CRM Consultant CDC Praxa Sydney, Australia http://mscrmshop.blogspot.com http://crm2011usersettings.codeplex.com
- Proposed as answer by Amreek Singh Friday, March 9, 2012 4:25 AM
- Marked as answer by Andrii ButenkoMVP, Moderator Sunday, March 11, 2012 8:17 PM
Friday, March 9, 2012 4:25 AM
All replies
-
You can't set the state of an entity in odata/rest end points. You need to use soap to do that.
It workd for both inbuilt and custom entities
here are the samples
http://dotnetdevlife.blogspot.com.au/2011/06/crm-2011-setting-state-from-jscript.html
http://mileyja.blogspot.com.au/2011/07/set-status-or-state-of-record-using.html
i hope this helps.
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Amreek Singh Senior CRM Consultant CDC Praxa Sydney, Australia http://mscrmshop.blogspot.com http://crm2011usersettings.codeplex.com
- Proposed as answer by Amreek Singh Friday, March 9, 2012 4:25 AM
- Marked as answer by Andrii ButenkoMVP, Moderator Sunday, March 11, 2012 8:17 PM
Friday, March 9, 2012 4:25 AM -
Amreek,
I was able to get this to work. However, the first link you posted has INCORRECT values for the state and status.
The second link has the correct values for state/status and this one worked for me. It wasn't until I "diff'd" the two items that I noticed the different state values.
Once, I corrected the values everything worked.
For INACTIVE records on my installation: State=1 / Status=2
For ACTIVE records: State=0/Status=1
-tomas
Friday, March 9, 2012 10:29 PM -
Good to hear that.
Could you please mark my post as answered.
thanks
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Amreek Singh Senior CRM Consultant CDC Praxa Sydney, Australia http://mscrmshop.blogspot.com http://crm2011usersettings.codeplex.com
- Proposed as answer by Kiran Madhav Friday, April 27, 2012 12:06 PM
Saturday, March 10, 2012 1:24 AM