- 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 03:23 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:17 AM
You need to do that on submit of client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2019 02:24 AM
Hi,
how can you check if there are still any open incident tasks in an incident without using GlideRecord as it is not allowed I think in a client script. Thanks
Regards,
Raphael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2019 02:51 AM
I didn't say without using GlideRecord you can handle it on submit and write the logic accordingly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-30-2019 02:52 AM
On submit make a GlideAjax request to check the task is closed or not and return the value. Based on the response show the error message.
