Notifications
Announcements
No record found.
Hi,
I want to update 'statuscode' & 'statecode' of accounts.
Can anybody suggest me?
*This post is locked for comments
there is a sample javascript function in this thread (ReactivateCase):
community.dynamics.com/.../250502
Hi Patel,
Below is the sample code to deactivate accounts. Similarly, you can use different statecode and statuscode based on your business needs.
For accounts:
State
Status Reason
0 : Active
1 : Active
1 : Inactive
2 : Inactive
var entity = {}; entity.statuscode = 2; entity.statecode = 1; var req = new XMLHttpRequest(); req.open("PATCH", Xrm.Page.context.getClientUrl() + "/api/data/v8.1/accounts(0000000-0000-0000-0000-000000000000)", true); req.setRequestHeader("OData-MaxVersion", "4.0"); req.setRequestHeader("OData-Version", "4.0"); req.setRequestHeader("Accept", "application/json"); req.setRequestHeader("Content-Type", "application/json; charset=utf-8"); req.onreadystatechange = function () { if (this.readyState === 4) { req.onreadystatechange = null; if (this.status === 204) { } else { Xrm.Utility.alertDialog(this.statusText); } } }; req.send(JSON.stringify(entity));
Hope it helps!
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
SA-08121319-0 4
Calum MacFarlane 4
Alex Fun Wei Jie 2