Change Task cannot be assigned to the same person as the previous Catalog Task.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2024 01:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2024 06:05 AM
update as this
function executeRule(current, previous /*null when async*/) {
var tsk = new GlideRecord('change_task');
tsk.addQuery('parent', current.parent);
tsk.addQuery('sys_id', '!=', current.sys_id);
tsk.query();
while (tsk.next()) {
if (tsk.assigned_to == current.assigned_to) {
gs.addErrorMessage('Change Task cannot be assigned to the same person as the previous Catalog Task.');
current.setAbortAction(true);
break;
}
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2024 12:22 AM
Hi Ankur,
the value of current.parent is empty in this code rule but in the table is the value available.
tsk.addQuery('parent', '==', current.parent);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2024 06:06 AM - edited 12-06-2024 06:07 AM
Hi @WilteS ,
(function executeRule(current, previous /*null when async*/) {
var tsk = new GlideRecord('change_task');
tsk.addQuery('parent', '==', current.parent);
tsk.addQuery('sys_id', '!=', current.sys_id);
tsk.query();
while(tsk.next()) {
if (tsk.assigned_to == current.assigned_to) {
gs.addErrorMessage('Change Task cannot be assigned to the same person as the previous Catalog Task.');
current.setAbortAction(true);
}
}
Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2024 12:21 AM
the value of current.parent is empty in this code rule but in the table is the value available.
tsk.addQuery('parent', '==', current.parent);