How to create an array or JSON variable in Flow Designer and use it?

gjz
Mega Sage

I have a business requirement to check the User table weekly and find all users who haven't logged into ServiceNow in the last 45, 90 and 120 days.  Based on the number of days (45 - 90, 90 - 120, 120+) a notification and task needs to be created.  I'm using the last_login field on sys_user in Flow Designer to find all users who meet the criteria.

 

Because a different notification/task is created based on how long the user hasn't logged in, it necessitates I query the User table three times in the same flow, which seems excessive to me.  I would like to query the table once and store the user's sys_id and number of days (using a custom date diff action) into a variable.  Then, in a For Each loop I will read the variable and create the correct notification/task based on the 45, 90, 120 day criteria.

 

My question is - how can I do that?  I need a 2 dimensional array to store the data from the User table, but I don't see an array as a flow variable type.  My next thought was I could use a JSON flow variable, but I've never used JSON variables and I don't know how to create them or use them in a flow.

 

Can someone help me with this, please?  TIA!

 

2 REPLIES 2

Maik Skoddow
Tera Patron
Tera Patron

Hi

keep the things simple when dealing with Flows! They are not intended to be a replacement of any programming language. They follow the no-code approach and should be built in a way that other users are able to understand and modify accordingly without any studies of rocket science.
Therefore, my recommendation is to build another subflow which takes the number of days as input parameter to perform the notification. In the main flow you could invoke the subflow x times with individual days as input parameters. So maybe this doesn't look highly optimized from a programming perspective, but everybody who looks at that flow would understand it.

Maik

Maik,

Thanks for the suggestion, it's certainly an option - but I was looking for information on how to create and use a JSON flow variable.  Do you know how to use it?