- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2024 01:42 PM
I am trying to make a scheduled job that runs once a day. The purpose of this scheduled job is to look into all active incidents which contain at least one person in the watchlist and remove any inactive users from the watchlist. Can anyone help with this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2024 05:02 PM
Ok, I built this out for the practice. Before we start, please be aware that Glide_List fields are simply strings that store comma separated sys_ids. Observe.
You'll also need to define two flow variables
- NewWatchList: this will store our valid user sys_id's to pump back into the watch list
- RemovedNames: This will store a string of friendly user names that we removed from the watch list. This isn't required, just going to make your Incident work notes more informative.
Here's the flow....
My first look up was just to a single sample Incident. You'd want to look up a set of records then do a For Each to loop through them. Anyway... here's what my sample incident started with. Akila P is inactive
My first For Each is simple. Just a For Each entry in the incident's Watch List.
Since the For Each is getting a user reference each time, lets ask if that user is active.
If the user IS active, lets pump their sys_id to flow variable NewWatchList, which is a string that will contain comma separated sys_ids. Don't copy this verbatim as the code will change based on the node you're pulling from and yours might not match mine. If you've never scripted values in flow you type in fd_data. and the system helps you fill in the rest. Its how you access your Data Picker via script. Super noice.
This code says "combine the NewWatchList variable with whatever its previous value was, plus a comma, plus the sys_id of the user I'm currently on in the For Each.
So if the user is NOT active, lets add their name to flow variable RemovedNames. Notice this time I'm not getting the user's sys_id, I'm getting their name!
Now that we've looped through all the users in the watch list, lets update the Incident. But we only need to update IF there were users to remove. We'll know if the cleanse was unnecessary if RemovedNames is not empty.
Now we just update the watch list (with NewWatchList) and then add a charming little work note to inform people which users have been removed from the watch list.
BOOM!! Cleansed watch list and informative work note if users were removed. (forgive me I was too lazy to hyper optimize the grammar of the work note update.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2024 04:04 PM
Hi @ValeriaS
That should have something out of box as they automatically remove assignee from Assigned To field.
I'll look further to that and reply here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2024 04:39 PM
@Luiz Lucena - It does not happen OOB. Not even for assignment. The sys_id is still in the reference field, its just not getting the display because the user is inactive.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2024 04:42 PM
Hi @Uncle Rob ,
Then I'll double check what we have done because we have something doing this.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2024 05:08 PM
Funny thing is... I think you can't select an inactive user for Assigned_To, but you CAN put an inactive user into watch list.