peterdelf
Giga Expert

I've just spent a few hours trying to create a scripted approval in Flow Designer that was previously quite simple in WorkFlow Editor.  As there weren't really any resources I found to do this on the web I thought I'd add an article here just in case there are any other admins/developers currently pulling their hair out trying to do this.

When using the out-of-box 'Ask For Approval' action you have the option of using a script for the 'Rules' section to determine who the approver should be.  In my company we don't have a feed of information for Heads Of Departments against Department values, so to do our 'requires HoD approval' I have to traverse an individual's line management chain until I get to someone with a job title of 'Head of Department'.  Luckily we'd already encapsulated that logic in a Script Include, here shown as 'FCARequestHelper().getHoD()'.  The tricky bit I found was actually trying to get to the catalog variables from a Service Catalog flow.

The example text you get in the comment at the top of a script says you should use 'fd_data.trigger.current...' in order to get to the current record.  This does not appear to work with a Service Catalog flow.  The values you are looking for for a Service Catalog flow are:

Requested Item record: fd_data.trigger.request_item

or

Flow Variables: fd_data._1__get_catalog_variables.variableNameHere

To get to the variables you need to have previously called the out-of-box action 'Get Catalog Variables' to have the above available to you.  Obviously if your 'Get Catalog Variables' is anything other than step 1 your fd_data property number will be different i.e. if it's step 2, the property will be _2__get_catalog_variables.

Hope this helps.

find_real_file.png

Comments
Sunny SN
ServiceNow Employee
ServiceNow Employee

Have you tried creating a new "Action" to get the data from tables and then calling it from the "Flow" (instead of the script)

 

find_real_file.png

 

find_real_file.png

 
Priya Rao
Tera Contributor

Hi @peterdelf ,

This article is helpful. I have a requirement to get the approval from the 'GVP of the Requestor'. We cannot directly dot-walk to that field, since it's not present in the form.

GVP is the management level. Every department has the GVP, by checking the Requestor's department we need to send an approval to their respective GVP's. Can you please let me know how can we achieve this?

 

Version history
Last update:
‎02-24-2021 01:51 AM
Updated by: