logo

NJP

Scripted dynamic Flow Designer approvals based off of information held in catalog variables

Import · Feb 24, 2021 · article

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.

image

View original source

https://www.servicenow.com/community/now-platform-articles/scripted-dynamic-flow-designer-approvals-based-off-of/ta-p/2318498