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);
                  }
            });
      
}


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