UI action validation

Ak8977
Tera Expert

Hello all,
in the change request table when I click review button, it need to validate the respective change tasks are in closed state or not. If all the change tasks are in closed state the it will go to review state else it need to show error. 
I updated the oob ui action. but it was not working. Could anyone help me on this.
The following is the ui action I have updated.

function moveToReview() {

/**script I created
var gr = new GlideRecord('change_task');
gr.addQuery('parent', current.sys_id);
gr.query();


while (gr.next()) {
if (gr.state == '3') {// state is clsoed
continue;
} else {
alert('Please close the Change Tasks');
return false;
//break;
}
}*/
g_form.setValue("state", "0");
gsftSubmit(null, g_form.getFormElement(), "state_model_move_to_review");

}

if (typeof window == 'undefined')
setRedirect();

function setRedirect() {
current.update();
action.setRedirectURL(current);
}

2 REPLIES 2

Sandeep Rajput
Tera Patron
Tera Patron

@Ak8977 You using alert in the server side script which might be causing the issue. Please update your script as follows.

 

function moveToReview() {

//script I created
var gr = new GlideRecord('change_task');
gr.addQuery('parent', current.sys_id);
gr.query();


while (gr.next()) {
if (gr.state == '3') {// state is clsoed
continue;
} else {
gs.addErrorMessage('Please close the Change Tasks');
return false;
//break;
}
}
g_form.setValue("state", "0");
gsftSubmit(null, g_form.getFormElement(), "state_model_move_to_review");

}

if (typeof window == 'undefined')
setRedirect();

function setRedirect() {
current.update();
action.setRedirectURL(current);
}

Hope this helps.

Hi Sandeep,

 

UI action button is not responding even after adding your logic to check for open tasks in related lists. the form remains same without any response.