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)

Change status reason through javascript

(0) ShareShare
ReportReport
Posted on by 1,680

Hi All,

I'm trying to change the Status Reason on Service Activity onchange of startdate field. Does any know hot to change it using the javascript.  Thanks in advance.

Drew

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Bruno Lucas Profile Picture
    5,421 on at

    Have you tried something like this:

    http://mileyja.blogspot.co.uk/2011/07/set-status-or-state-of-record-using.html

    mscrmdeveloper.wordpress.com/.../update-status-reason-using-javascript

  • Verified answer
    Royal King Profile Picture
    27,686 on at

    You should be able to use below code to set status reason of an service activity

    Xrm.Page.getAttribute("statuscode").setValue(integervalue of statusreason );  

    Integer    - Status reason 

    1 - Requested

    2 - Tentative

    3 - Pending

    4 - Reserved

    6 -  In Progress

    7 - Arrived

  • Suggested answer
    Dynamics Monster Profile Picture
    471 on at

    I would use the SetState: A JavaScript Function to perform a set state soap request, and is the right option to take, even from server side, if i need to change the status i would use the setstate request, and in javascript you can use either sopa or rest. In the SDK  you will find how to do.

  • Drew Inc. Profile Picture
    1,680 on at

    Chitrarasan Duraisamy - I read somewhere you cant set it this way, however I tried after you suggested it. It works like a charm

    Thanks everyone.

  • Suggested answer
    SN Dwivedi Profile Picture
    20 on at

    You can use javascript to do it but before using javascript you will have to save the activity and then update Status field using JavaScript. I was also having same issue in PhoneCall entity and then I tried so many articles .

    try something like this -

    blog.infobitsoft.com/.../how-to-change-the-status-value-in-ms-dyanmics-365-using-javascript.html

  • Suggested answer
    Abhishek Parasher Profile Picture
    10 on at

    Hello Drew Inc. and everybody, the answers posted here are following old approaches. After the D365 CE v9.0 has arrived, Microsoft has strongly suggested us to use XrmWebApi functions. In the following piece of JavaScript code, I am updating the status of a Case (incident) record to 'Waiting for Details' with the help of Xrm.WebApi.updateRecord method. Please consider. :)

    function UpdateCaseStatus(executionContext)

    {

    var formContext = executionContext.getFormContext();

    var entityId = formContext.data.entity.getId().substring(1, 37);

    debugger;

    var incidentData = {

    "statecode": 0,

    "statuscode": 3

    };

    Xrm.WebApi.updateRecord("incident", entityId, incidentData).then(function success(result)

    {

    formContext.data.refresh(true);

    }, function (error)

    {

    formContext.data.refresh(true);

    });

    }

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