If the assigned to user was inactive, then clear out the users name from the list of tasks assigned to him.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2022 05:23 AM
Hi Team,
If the assigned to user was made inactive (in user record), then clear out the users name from the list of task's assigned to him.
How can I approach it, Please help me on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2022 05:29 AM
HELLO
YOU CAN WRITE A AFTER UPDATE BR ON SYS_USER TABLE
where the condition can be like active changes to false
then the script can be like below
var gr = new GlideRecord('task');
gr.addQuery('assigned_to',current.sys_id);
gr.query();
while(gr.next())
{
gr.assigned_to ="";
gr.update();
}
Hope this helps
please mark my answer correct if this helps you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2022 05:30 AM
Hi,
Try this
(function executeRule(current, previous /*null when async*/) {
var user = current.getValue("sys_id"); //should usually use a string version of the data
var inc = new GlideRecord("incident");
//added extra filter so closed/cancelled records are not re-assigned
inc.addEncodedQuery("active!=true^assigned_to=" + user);
inc.query();
while(inc.next()){
inc.assigned_to = "";
inc.update();
}
})(current, previous);
Reference : business rule when a user is inactive
Mark Correct or Helpful if it helps.
***Mark Correct or Helpful if it helps.***

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2022 05:30 AM
Hi Feroz,
You need an after update BR on User table that runs when Active | changes to | false with script as below.
(function executeRule(current, previous /*null when async*/ ) {
var setemptyassignedto = new GlideRecord('task');
setemptyassignedto.addQuery('active', 'true');
setemptyassignedto.addQuery('assigned_to', current.sys_id);
setemptyassignedto.query();
while (setemptyassignedto.next()) {
setemptyassignedto.assigned_to = '';
setemptyassignedto.work_notes='Assiged to changed to empty as user is inactive';
setemptyassignedto.update();
}
})(current, previous);
For existing records try below as background script.
var setemptyassignedto = new GlideRecord('task');
setemptyassignedto.addQuery('active', 'true');
setemptyassignedto.addQuery('assigned_to.active', 'false');
setemptyassignedto.setLimit(10);//do for 10 records first
setemptyassignedto.query();
while (setemptyassignedto.next()) {
gs.print('Records updated are '+setemptyassignedto.number);
setemptyassignedto.assigned_to = '';
setemptyassignedto.work_notes='Assiged to changed to empty as user is inactive';
setemptyassignedto.update();
}