Error Message is not displaying when action is aborted.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2023 11:09 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2023 11:17 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2023 11:26 PM
Yes tried but it is not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2023 11:39 PM
Hi @Sweenal ,
You've 3 error messages which one is not getting printed ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2023 11:44 PM
None of them is getting printed.