I am trying to change the state code and status code from Open ,Open to Completed and Closed , I have written the code for that below is the code, I have pasted the error, Please Help me
async function systemLogClose(executionContext)
{
      var formContext = executionContext.getFormContext();
      var statecode = formContext.getAttribute("statecode").getValue();
      var statusreason = formContext.getAttribute("statuscode").getValue();
      var fetchXml = "?fetchXml=<fetch>" +
            "<entity name='lgr_systemlog'>" +
            "<attribute name='activityid'/>" +
            "<attribute name='subject'/>" +
            "<attribute name='createdon'/>" +
            "<order attribute='subject' descending='false'/>" +
            "<filter type='and'>" +
            "<condition attribute='regardingobjectid' operator='not-null'/>" +
            "</filter>" +
            "</entity>" +
            "</fetch>";
      await Xrm.WebApi.online.retrieveMultipleRecords("lgr_systemlog", fetchXml).then(
            function success(result) {
                  if( statecode ==0 && statusreason == 1) // 0 = Open and 1 = Open
{
                        formContext.getAttribute("statecode").setValue(1); // Completed
                        formContext.getAttribute("statuscode").setValue(2); // Closed
}
                  
            });
}
I am getting the below error
Exception Message: 2 is not a valid status code for state code lgr_systemlogState.Open on lgr_systemlog with Id 0e5cabbe-af6b-ed11-81ac-0022481b5c47.
ErrorCode: -2147187704
HexErrorCode: 0x80048408
ErrorDetails:
      ApiExceptionSourceKey: Plugin/Microsoft.Crm.ObjectModel.CustomActivityService
      ApiStepKey: 6190c079-2f6a-ed11-81ac-0022481b5f3c
      ApiDepthKey: 1
      ApiActivityIdKey: 559d3bc4-e840-4eb5-945e-03ad8b7cf809
      ApiPluginSolutionNameKey: System
      ApiStepSolutionNameKey: System
      ApiExceptionCategory: ClientError
      ApiExceptionMessageName: InvalidStateCodeStatusCode
      ApiExceptionHttpStatusCode: 400
Activity Id: 5da8d406-4e35-4204-abdb-d0181209fbac