web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to change status and status reason of the current entity on button click

(0) ShareShare
ReportReport
Posted on by 12,119 Moderator

Hi All,

On the button click I wrote below code:

function ActionApprove() {
    try {
        debugger;
        Xrm.Page.getAttribute("statecode").setValue(1);
        Xrm.Page.getAttribute("statuscode").setValue(2);
        Xrm.Page.data.entity.save();
        Xrm.Page.data.refresh();
    } catch (e) {
        alert("Error in ActionApprove: " + e);
    }
}

But it do nothing. What is wrong with it. Please help.

Thanks

Regards,

Abdul

*This post is locked for comments

I have the same question (0)
  • gdas Profile Picture
    50,091 Moderator on at

    Hi ,

    Try with web api, here is sample code -

    syednizamsyed.blogspot.com/.../change-record-status-through-webapi-in.html

  • Abdul Wahab Profile Picture
    12,119 Moderator on at

    Hi Goutam,

    Thank you for your reply. Previously we used above way to update current entity with the help of Java Script. Is there any change? I am having this issue when I upgrade my CRM  to 9 version.

    I know the method of web API for update and I am already using it.

    Thanks

    Regards,

    Abdul

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    I don't think any changes has made , however your code ia correct.

    BTW which entity are you updating the status?

    You can try your code for other entity as well to make sure your code is working correctly. Might be the entity you are updating which is associate with plugin or workflow which causes the problem.

    In addition I would suggest try with the reference which i shared above , just replace entity name and the state code , status code value.

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.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Varsha deshpande Profile Picture

Varsha deshpande 5

#2
JS-09031509-0 Profile Picture

JS-09031509-0 3

#3
Ciprian  P Profile Picture

Ciprian P 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans