Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

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

Posted on by 12,070 Super User 2024 Season 1

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

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: How to change status and status reason of the current entity on button click

    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.

  • Abdul Wahab Profile Picture
    Abdul Wahab 12,070 Super User 2024 Season 1 on at
    RE: How to change status and status reason of the current entity on button click

    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

  • gdas Profile Picture
    gdas 50,085 on at
    RE: How to change status and status reason of the current entity on button click

    Hi ,

    Try with web api, here is sample code -

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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans