Flow Variable - Looking up Manager from Sys ID String off History Table
This content was last updated in 2023. It may still be useful, but could contain outdated information. Please confirm its accuracy before relying on it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2023 05:38 AM
Hey guys - QQ on Flow Designer - I am setting up a flow that triggers when an INC has been reassigned 3 times and it emails all assignees. I have this working by doing a Look Up on the history table for that INC where the field is assigned_to, doing a for each and setting a variable for assignee and sending them each an email - I want to copy the assignees manager, but can not figure out how to get it - in my mind I should be able to do a lookup back to the user table, joining on sys ID, and getting the manager but it doesn't work. I then though maybe I could script it, but it returns no value
I was hoping to be able to do a lookup using the user sys id string to the user table and then get the manager info that way - or even using a script like this - this works in background script (replacing my variable with a string user sys id), but not in Flow.
/*
**Access Flow/Action data using the fd_data object. Script must return a value.
**Available options display upon pressing "." after fd_data
**example: var shortDesc = fd_data.trigger.current.short_description;
**return shortDesc;
*/
var currentUser = fd_data.flow_var.assignee.manager;
var getUserData = new GlideRecord('sys_user');
if(getUserData.get(gs.getUserID(currentUser)))
{
gs.info(getUserData.manager.manager);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-13-2023 02:48 PM - edited 07-13-2023 02:49 PM
Very first, I would check and make sure you have the Application Cross-Scope Access records you need. When I ran a background script in my custom app scope against the sys_history_line and sys_history_set tables, it created Application Cross-Scope Access records for me. I don't know if Flow Designer does that automatically, so you will want to double check that they exist.
If that doesn't resolve the issue, I would remove steps 4 & 5 and then create a brand new "Set Flow Variables" step within the for loop with the following script:
return fd_data._3__for_each.item.set.id.assigned_to.manager.sys_id + "";
From there, you should be able to look up the user based on the sys_id saved in the new flow variable.
Alternatively, you might be able to skip the scripting and/or flow variable entirely and dot walk to the manager from the data pill picker in the for loop (for loop item record > Set > ID > Assigned to > Manager).
Hope that helps or at leasts points you in the right direction!