Site Loader
Change the Activity Status (StateCode) value using JavaScript in Microsoft Dynamics 365 / PowerApps

There are so many questions in Microsoft community forum regarding to Change the Status using JavaScript but none of them have explained it completely. If any beginners wants to use JavaScript to change the Status value in the Activity then they will not be able to do it in right way.

Also Read – How to create a clone record in MS Dynamics 365 using JavaScript

I am going to explain you the easy way to change the Status value in the Entity using JavaScript. Believe me you will not need to add any JavaScript  library or any other XrmSvcToolkit. In some articles I saw they have mentioned that you will need to make request to the SOAP API to change the state value. So here I am going to explain you why we will not need anything mentioned above.

Also Read – How to get and set Lookup field in MS Dynamics 365 using JavaScript

There are so many ways to change the Status value like you can use Workflows, Microsoft flow or Plugins. I had a requirement to save the record and change the Status field value and clone the record. So I just wrote a JS function and called that using custom button, everything is working like charm.

Also Read – How to connect Microsoft SharePoint Online using PHP

To change the Status field value you will need to save the current record and then you will be able to change the Value. So here is the JavaScript function which I am using to change the Status (Activity Status) value. I have add this code into my Phone Call entity form.

Also Read – How to connect Quickbooks Online using Microsoft Flow Connector

Here is the Code – 

function updateStatus() {, function () { });

function saveAndUpdate(){“statecode”).setValue(1);;


If you guys have any other best way to do it then please let me know in the comment box.

If you find this blog post helpful then Please share it with your friends on Social media. Thank you.

Post Author: admin

Leave a Reply

Your email address will not be published. Required fields are marked *