Skip to main content

Notifications

Announcements

No record found.

Service | Customer Service, Contact Center, Fie...
Suggested answer

I want to change the status reason from "Not started" to "In progress" using Java script code.Pleas help me by providing some piece of code

(0) ShareShare
ReportReport
Posted on by 42

I want to change the status reason from "Not started" to "In progress" using Java script code16684942340606498206142777362165.jpg

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: I want to change the status reason from "Not started" to "In progress" using Java script code.Pleas help me by providing some piece of code

    learn.microsoft.com/.../updaterecord

    This post contains everything you need. Good luck.

  • saikrishna963 Profile Picture
    saikrishna963 42 on at
    RE: I want to change the status reason from "Not started" to "In progress" using Java script code.Pleas help me by providing some piece of code

    Can you update my code with update record method

  • saikrishna963 Profile Picture
    saikrishna963 42 on at
    RE: I want to change the status reason from "Not started" to "In progress" using Java script code.Pleas help me by providing some piece of code

    Can you update my code with update record method

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: I want to change the status reason from "Not started" to "In progress" using Java script code.Pleas help me by providing some piece of code

    For your second part that doesn't work you will have to update statecode and statuscode the same time and I believe you will be able to do that using Xrm.WebApi.updateRecord

  • saikrishna963 Profile Picture
    saikrishna963 42 on at
    RE: I want to change the status reason from "Not started" to "In progress" using Java script code.Pleas help me by providing some piece of code

    Hi, 

          async function serviceActivityOnLoad(executionContext)

    {
          debugger;
          var formContext =executionContext.getFormContext();
          var statusreason = formContext.getAttribute("statuscode").getValue();
          var serviceId = formContext.getAttribute("serviceid").getValue()[0].id;
          var fetchXml = "?fetchXml=<fetch>" +
    "<entity name='service'>"+
    "<attribute name='serviceid'/>"+
    "<filter type='and'>" +  "<condition attribute='serviceid' operator='eq' value='" + serviceId + "'/>" +
    "</filter>" +
    "<link-entity name='lgr_processtype' alias='processType' link-type='inner' from='lgr_processtypeid' to='lgr_processtypeid'>"+
    "<attribute name='lgr_isautoactivitychangetoinprogress' />" +
    "</link-entity>"+
    "</entity>"+ "</fetch>";
          
          await Xrm.WebApi.online.retrieveMultipleRecords("service", fetchXml).then(
                function success(result) {
                      
                      if (statusreason == 799900000 && result.entities[0]['processType.lgr_isautoactivitychangetoinprogress@OData.Community.Display.V1.FormattedValue'] == "Yes")
                             {
                            formContext.getAttribute("statuscode").setValue(6);
                      } else
                            {
                            formContext.getAttribute("statuscode").setValue(799900000);
                      }
                });
          

    }

    6663.MicrosoftTeams_2D00_image-_2800_5_2900_.png4075.MicrosoftTeams_2D00_image-_2800_6_2900_.png

    That is my  code all the code works but in if condition the logic is failing to set statuscode to 6. while I am trying with setStatus(2) ( where 2 means requested ) it is working. But for 6 it is not working 6 means Inprogress which is from Scheduled, while Not started is from Open

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: I want to change the status reason from "Not started" to "In progress" using Java script code.Pleas help me by providing some piece of code

    Then create a webresource, add it to the form and add OnLoad event handler pointing to changeStatusCode. Don't forget to check "Pass Execution Context" checkbox.

    Check this - debajmecrm.com/.../

  • saikrishna963 Profile Picture
    saikrishna963 42 on at
    RE: I want to change the status reason from "Not started" to "In progress" using Java script code.Pleas help me by providing some piece of code

    I have to change that on formonload event

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: I want to change the status reason from "Not started" to "In progress" using Java script code.Pleas help me by providing some piece of code

    Hello,

    I'm not sure what's the trigger for your code but here is how it should approximately look like:

    function changeStatusCode(executionContext){

    var formContext = executionContext.getFormContext();

    formContext.getAttribute("statuscode").setValue(<replace this with In Progress 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

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 Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,503 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans