Error Message is not displaying when action is aborted.

Sweenal
Tera Contributor

Hi All,

Please help me with below requirement:

I have created one custom UI Action Button Add in related list of incident form.

In which if i click on add button and if the incident which I have selected is major incident or if that incident is of higher priority than the current incident then it should not get added and action should be aborted and error message should be printed.

The script which I wrote is working on existing edit button but the button I made when I am adding the incident is aborting the action but error message is not getting printed. I want that error message and abort action whenever I click on button and select the incident.

Below is the Business Rule Script Before Insert and Update:

gs.log("Priority" + current.priority, "ab");
var count;
var gr = new GlideRecord("incident");
gr.addQuery("parent_incident", current.sys_id);
//gr.addEncodedQuery('child_incidentsGT_FIELDparent_incident.priority');
gr.query();
while (gr.next()) {
if (current.priority > gr.priority) {
count = gr.getRowCount();
gs.log("Count" + count, "abc");
if (count > 1) {
gr.parent_incident = "";
gr.update();
gs.addErrorMessage('Child with higher priority is removed');

}
}
if (gr.major_incident_state == 'accepted') {
gr.parent_incident = "";
gr.update();
current.setAbortAction(true);
//current.setWorflow(false);
gs.addErrorMessage("Major incident cannot be set as child incident");

}

}
gs.log("Count" + count, "abcd");
if (current.parent_incident != '') {
var parentinc = current.parent_incident.priority;
if (current.priority < parentinc) {
current.parent_incident = '';
gs.addErrorMessage('Cannot submit higher priority');
current.setAbortAction(true);
//current.setWorflow(false);
}
}

 

 

Thanks & Regards,

Devyani

9 REPLIES 9

Dhruv Chandan
Giga Guru

Hi,

 

Can you set the error message after the abort action like below :-

 

current.setAbortAction(true);
gs.addErrorMessage('Cannot submit higher priority'); // This should work now.

 

Hope this helps.

 

Regards,
Dhruv

@Dhruv Chandan 

Yes tried but it is not working.

Community Alums
Not applicable

Hi @Sweenal ,

You've 3 error messages which one is not getting printed ?

None of them is getting printed.