Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Flow Variable - Looking up Manager from Sys ID String off History Table

goldenjc97
Tera Expert

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 

 

image.png

 

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);
}

 

image_720.png

 

1 REPLY 1

Aylee Andersen
Kilo Sage

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!