In Dynamics 365, OOTB status field value can be changed in many different ways.
Following WebApi can be used to update the Status (statecode + statuscode) as follows.
changeStatus = function (executionContext, entityLogicalName, recordId, statecode, statuscode) {
// Remove brackets from the GUID if there’s any
var id = recordId.replace(“{“, “”).replace(“}”, “”);
// Set statecode and statuscode
var data = {
“statecode”: statecode,
“statuscode”: statuscode
};
// WebApi call
Xrm.WebApi.updateRecord(entityLogicalName, id, data).then(function success(result) {
executionContext.getFormContext().data.refresh(true);
}, function (error) {
executionContext.getFormContext().data.refresh(true);
});
};