Need help with creating a script in flow designer, there is no step where script can be made?

snow_beginner
Mega Guru

Hi,

 

I have requirement to build a flow to basically monitor when an integration last worked.

 

In my instance there is a platform integrations table, which recently has a new section added to it called monitoring. I have attached a ss of it below.

 

Pasted image.png

What the flow is meant to do is go to this integrations table, and find all the integration records which are active=true and the table field is not empty and the conditions are not empty.

 

From there it needs to go to the target table found in the table field above, apply the conditions mentioned above to the target table and if any records meet the condition then come back to the above table and tick the conditions met checkbox and update the conditions last met field with the current date/time.

 

What I have so far is the following:

 

step 1) Trigger every 3 hours

 

step 2) action > Look up records > table: platform_integrations

conditions: active is true AND table is not empty AND conditions is not empty

 

step 3) for each loop found in step 2...I don't know what to do here because there is no simple script step in my instance where I can add the script. 

 

I know there is a toggle script for look up records, update record and create record actions, would that be something that's used here?

 

Because my understanding was that the toggle script for something like update record would only work on the fields of that record, it won't go to the target table, get relevant records and update the record in another table...or would it work like that?

 

Please guide me on how I can do this. Thanks!

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@snow_beginner 

it worked for me in flow itself, no flow action required

You need to use inline script in the Lookup Records condition field so that it picks conditions dynamically

See below

Please enhance it further to use IF logic to check the count and then Update the checkbox using "Update Record" flow action

flow conditions (1).gif

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@snow_beginner 

create a custom flow action, accept 1 string as input and other input as table name, have output as count

In that flow action, you can use script step and use GlideRecord and encoded query (use the condition passed as input), set the count as output variable

you will have to use Lookup Records on that table and then call that flow action, then use IF logic to know the count and based on count 0 or more than o you can update that checkbox

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

@snow_beginner 

it worked for me in flow itself, no flow action required

You need to use inline script in the Lookup Records condition field so that it picks conditions dynamically

See below

Please enhance it further to use IF logic to check the count and then Update the checkbox using "Update Record" flow action

flow conditions (1).gif

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@snow_beginner 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi @Ankur Bawiskar thanks so much for the video demo. I have decided to use this approach after speaking to my senior dev and I think it will work well.