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

Notifications

Announcements

No record found.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans