closing of problem record only when all the problem tasks are closed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2021 06:20 AM
Hi everyone,
In problem record , problem record will be closed only when all the ptasks are closed complete. before the record is closed then a message should be display please close the ptask .
if we cancel the problem record then all the problem task will be changed to closed complete auttomatically.
- Labels:
-
Problem Management

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2021 06:31 AM
Hi,
Create a before Update BR on Problem table with condition as
Problem Status changes to closed
and use the following in script
var gr = new GlideRecord('problem_task');
gr.addQuery('active','true');
gr.addQuery('problem',current.sys_id);
gr.query();
if (gr.next()) {
gs.addInfoMessage(gs.getMessage("A task is open. Please complete the task before closing the problem ticket."));
current.setAbortAction(true);
}
Mark ✅ Correct/helpful, if applicable, Thanks!!
Aman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2021 06:38 AM
if we cancel the problem record then all the problem tasks will be changed to closed complete auttomatically.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2021 07:02 AM
If you have the Cancel UI Action follow what Ankur suggested.
Your initial query is answered, close the thread by marking appropriate answer as correct.
Just a suggestion, try to build it by yourself if they are your assignments during your training period.
Thanks,
Aman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-01-2021 06:51 AM
for this point
if we cancel the problem record then all the problem task will be changed to closed complete auttomatically.
I assume you must be having Cancel UI Action on Problem table
Server Side Script in UI Action:
(function(){
try{
// your code
var gr = new GlideRecord("problem_task");
gr.addQuery("problem", current.getUniqueValue());
gr.query();
while(gr.next()) {
gr.state = 157; // closed
gr.update();
}
}
catch(ex){
gs.info(ex);
}
})();
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader