Check sample code for refernce

function rma_complete() { // Same as OnClick
    var reason = prompt("Enter reason for force closure this request");
    if (reason != " ") {
        g_form.setValue('comments', g_user.firstName + " " +reason);
        gsftSubmit(null, g_form.getFormElement(), 'rmaclose');
    } else {
        return false;
    }
}
//Code that runs without 'onclick'
//Ensure call to server-side function with no browser errors
if (typeof window == 'undefined')
    rmagotocls(); //change to next stage

function rmagotocls() { //change to next stage, same as above
    //current.comments = "reason: " + reason;
     current.description = 'hello.testing';
    current.update();
    action.setRedirectURL(current);
}

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
5x ServiceNow MVP

View solution in original post