- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2019 01:53 AM
Hello,
I have a task wherein I have to create an error message using client script. The scenario is whenever a user changes the state of the incident to resolve and an incident task or job order is still open, it will display an error message which says "Please Close all incident tasks" or "Please Close all Job orders" after submitting the incident. Thank you.
Regards,
Raphael
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
-
Team Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2019 03:30 AM
HI,
Please write a Business rule on the INcident table
When to run ->Before,Update
Action-> state To close
Advance code:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('incident_task);
gr.addQuery('active','true');
gr.addQuery('incident',current.sys_id);
gr.query();
if (gr.next()) {
gs.addErrorMessage('Incident cannot be closed before the incident task closure');
current.setAbortAction(true);
}
})(current, previous);
Please mark reply as Helpful/Correct, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2019 02:26 AM
hi
You can use alert() message or g_form.addErrorMessage(message). When do you want this error message to be displayed? When user submits the form?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2019 02:41 AM
Hi,
Yes I want this error to show whenever a user changes the incident to resolve and updates it and it will only show when an incident task is still open
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2019 03:30 AM
HI,
Please write a Business rule on the INcident table
When to run ->Before,Update
Action-> state To close
Advance code:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord('incident_task);
gr.addQuery('active','true');
gr.addQuery('incident',current.sys_id);
gr.query();
if (gr.next()) {
gs.addErrorMessage('Incident cannot be closed before the incident task closure');
current.setAbortAction(true);
}
})(current, previous);
Please mark reply as Helpful/Correct, if applicable. Thanks!
