- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 02:29 AM - edited 11-28-2023 02:33 AM
Hi Team
How to restrict assigning 2 sctasks to a same member when the tasks are generated from same ritm .
I have wirtten this BR on ritm table ,
Here we are triggering sequential task . I am going to assign same person to 2nd task it should through an error .Which is not working ,
Note - it should throw an error and abort action
Please help me here , please provide solution
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 03:04 AM
Hi @nameisnani ,
You should create before insert and update business rule on sc_task table i have tried in my pdi its working.
(function executeRule(current, previous /*null when async*/) {
var ritm = new GlideRecord('sc_req_item');
if (ritm.get(current.request_item)) {
var existingTasks = new GlideRecord('sc_task');
existingTasks.addQuery('assigned_to', current.assigned_to);
existingTasks.addQuery('request_item', current.request_item);
existingTasks.addQuery('sys_id', '!=', current.sys_id);
existingTasks.query();
if (existingTasks.hasNext()) {
gs.addErrorMessage('Another task is already assigned to the same member for this RITM. Please review the assignments.');
current.setAbortAction(true);
}
}
current.setAbortAction(false);
})(current, previous);
Mark it as solution proposed and helpful if it serves your purpose.
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 02:35 AM
Hello @nameisnani
As I can see you have written BR on RITM table but you should have to write this BR on the SC Task Table then only this will work.
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 02:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2023 03:04 AM
Hi @nameisnani ,
You should create before insert and update business rule on sc_task table i have tried in my pdi its working.
(function executeRule(current, previous /*null when async*/) {
var ritm = new GlideRecord('sc_req_item');
if (ritm.get(current.request_item)) {
var existingTasks = new GlideRecord('sc_task');
existingTasks.addQuery('assigned_to', current.assigned_to);
existingTasks.addQuery('request_item', current.request_item);
existingTasks.addQuery('sys_id', '!=', current.sys_id);
existingTasks.query();
if (existingTasks.hasNext()) {
gs.addErrorMessage('Another task is already assigned to the same member for this RITM. Please review the assignments.');
current.setAbortAction(true);
}
}
current.setAbortAction(false);
})(current, previous);
Mark it as solution proposed and helpful if it serves your purpose.
Thanks,
Anand