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

Community Alums
Not applicable

Hi @Sweenal ,

You need to create UI action and copy paste the same script in it. It's working fine for me.

 

demopic.png

 

Mark it Helpful, If it works.

Khasim.

@Community Alums 

Actually in UI Action I have written other script  in which UI Page is created and script include is called in UI Action so how i will add this script here.

Community Alums
Not applicable

You can create new UI action

@Community Alums 

But I Want to make the functionality work on same add button.

Hi,

 

Did you manage to fix the issue ? If yes, please share how ?