Retrieve User ID in Flow Designer from a user select list variable

trmcclain
Tera Contributor

We currently have automation set up between our SN instance and Jira which allows us to add users to application access groups once a task is created for our assignment group. In this instance using 

fd_data.trigger.current.variables.users.getDisplayValue() is sufficient.
However while trying to design similar automation for a different toolset, I need to be able to grab the underlying user id (in my company's case a 6 digit alphanumeric) from the 'users' variable.
I can get the sys_id of the values if I drop the getDisplayValue(), but from there I haven't been able to successfully transmute it into the user Id I need. On top of that I can't even see the class to realize what kind of object I'm dealing with. 
Can anyone point me to a good resource to assist in this regard?
I can provide more context if needed.
The code I'm using currently is very basic:

 

var names = fd_data.trigger.current.variables.users.getDisplayValue()//user variable
var just = fd_data.trigger.current.variables.business_justification_program_requirements.getDisplayValue();

var desc = just+"\nUsers: "+names;

return desc

 

6 REPLIES 6

That is a list collector so it can hold multiple values. What do you want to have happen if there are 3 users? Or is it always just 1?

Amit Verma
Kilo Patron
Kilo Patron

Hi @trmcclain 

 

I assume that you are trying to fetch the user id's from the list collector variable. You can easily do it using flow designer. Please follow the below steps :

 

1. Design a flow with trigger as Service Catalog which has your list collector variable.

2. Use Get Catalog Variables action to extract List Collector Variable.

3. Use Custom Action "Get List Collector Items" which you can make by taking reference from the link https://www.servicenow.com/community/developer-blog/using-list-collector-in-flow-designer-for-each-l...

4. Use a for each loop on the above action output and inside the for each, make use of lookup record through which will get you the user record. You can dot walk on this to get the user id.

 

I have attached the update set containing the flow and action for your reference. Please import it on your development instance and give it a try.

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.