State Status Code Update On ServiceActivity Entity

// JavaScript source code
//var Id = Xrm.Page.data.entity.getId().replace("{","").replace("}","");
function changeStatus() {
    debugger;
        //Set the stage to send enquiry letter
        XrmSvcToolkit.setState({
            id: Xrm.Page.data.entity.getId().replace("{", "").replace("}", ""),
            entityName: "serviceappointment",
            stateCode: 0,
            statusCode: 1, //New
            async: false,
        });
    //Save and Reload form
        updateService();
     
        Xrm.Page.data.refresh(true);
}

function updateService() {
    debugger;
    XrmSvcToolkit.updateRecord({
        entityName: "ServiceAppointment",
        id: Xrm.Page.data.entity.getId().replace("{", "").replace("}", ""),
        entity: { Category: "A.Purushotham" },
        successCallback: function (result) {
            alert("success" + result);
            debugger;
            statusclose();
        },
        errorCallback: function (error) {
            debugger;
            alert(error.message);
        }
    });
}
function statusclose() {
    XrmSvcToolkit.setState({
        id: Xrm.Page.data.entity.getId().replace("{", "").replace("}", ""),
        entityName: "serviceappointment",
        stateCode: 1,
        statusCode: 8, //New
        async: false,
    });
}

Comments

Popular posts from this blog

Meta Data Using WebApiRequest

Sample CRUD Operations Using C# in MSCRM

Basic Plugin Code in D365 using C#