Sandeep Rajput
Tera Patron

@Shidhi Please try the following.

 

function cancelTask() {
var closeNotes = g_form.getValue('close_notes');
    if (closeNotes=='') {
        g_form.setMandatory('close_notes', true);
        g_form.showFieldMsg('close_notes', 'Enter Close Notes', 'error');
        return false;
    } else {
        alert('Cancelling the task');
        gsftSubmit(null, g_form.getFormElement(), 'cancelRecord');
	
	}
}
        if (typeof window == 'undefined') {
            cancelTaskRecord();
        }
        function cancelTaskRecord() {
        current.state = '4';
        current.update();
        action.setRedirectURL(current);
        }