- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 06:27 AM
Hi,
I need to close incident when incident task is closed. Which approach should we use before and after business rule and how to achieve that.
Can anyone please help me with that.
Regards,
Nivedita
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 06:55 AM
I am not a pro or coder , but my experience with technical team says, here, go with After BR.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 06:31 AM
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 06:52 AM
Hi @Dr Atul G- LNG,
I'm more focusing on which approach would be better Before or After business. I have written for same on request and task table.
Can you please confirm in that type of use case which approach we should use Before or After business rule.
Regards,
Nivedita
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 06:55 AM
I am not a pro or coder , but my experience with technical team says, here, go with After BR.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 07:14 AM
You can go with 'after' business rule and try checking if your issue is resolved.
Else , use this code
(function executeRule(current, previous /*null when async*/) {
var count=0;
var tasks = new GlideRecord('incident_task');
tasks.addQuery('parent',current.parent);
tasks.query();
var taskcount = tasks.getRowCount();
while(tasks.next())
{
if(tasks.state == 3 ||tasks.state == 4 || tasks.state == 7)//change as required
{
count++;
}
}
if(count == taskcount)
{
var inc = new GlideRecord('incident');
inc.addQuery('sys_id',current.parent);
inc.query();
if(inc.next())
{
inc.state = 6;
inc.update();
}
}
Hope it helps.
Regards,
Kiranmai.
})(current, previous);