What I am trying to do:
I am building a workflow that get the description of a ServiceNow incident and parses it for IPs and usernames. I then will be using the IPs to querying Microsoft log analytics to get the list of users that authenticated with that IP and then match the list of users in the ticket against the users returned from the query.
Problem:
I would like to check to see if any of the users that are returned in the results are in the list of users pulled from the ticket description. However, the only way I can think of doing this is by nesting a loop inside of another loop, which I have done in the past. Doing it this way just feels wrong and it adds to the overall run time of the workflow. It also makes it difficult when I need to return data from the outer loop.
This is how I have done it in the past (pseudocode) :
for each queryUser in userReturnedFromQuery
(
for each userReported in usersFromTicket
(
if queryUser == userReported then
if userMatched == False
userMatched = True (added to artifacted used as output)
else
*empty branch*
else
*empty branch*
)
if userMatched == True then
-add information an artifact
)
Question:
Is there a better way to check for values that are inside an array for InsightConnect? I know I will need to have at lest one loop, but I am looking for a way to quickly and efficantly search arrays without a nested loop. For large sets of data, this just increases the time for the workflow to run. For one of my workflows I stopped creating loops inside of loops when I knew there would be a lot of data to loop through. Instead, I just dumped the list of items into a global artifact and then use a helper to search the global artifact. The downside to this is needing to clear the global artifact at the end of the workflow.
I found an article for InsightDR, but I could not find anything similar for InsightConnect. What I found for InsightDR: Searching array without using Index