Issue with current being undefined in Flow Designer

Aaron Duncan
Mega Sage

I'm using Flow Designer to send a reminder email to approvers that they have pending approvals to perform. I also want to increment a field to show how many times the notification had to be sent before action was performed. This should be a simple script to update the counter, but I'm running into the following error. 'attempting to use undefined input = 'current' from' This looks up records from the sysapproval_approver table and sends an email based on each approval waiting. I have that part working, however the following code is giving me issues (the field u_number_of_reminders is already created and on the form).

/*
**Access Flow/Action data using the fd_data object. Script must return a value.
**example: var shortDesc = fd_data.trigger.current.short_description;
**return shortDesc;
*/
var x = fd_data.trigger.current.u_number_of_reminders;
x++;
return x;

 

find_real_file.png

4 REPLIES 4

Daniel Draes
ServiceNow Employee
ServiceNow Employee

Your flow is triggerd as 'daily at' ... with that the flow has no triggering record. fd_data.trigger accesses triggering records.

 

In your case you will need to use the data pills to get to the record currently being processed. From the top of my head it would need to look something like:

 

fd_data.for_each_2.approval_record._number_of_reminders.

 

Not sure on the exact notation... but close 😄

I can use the data pills to reach the field, but none of the transform functions allow me to increment the field by 1. If that part can be solved for, I'd love to use this.

 

find_real_file.png

How about you define a flow variable and use the set variable action to set and increment it? Didn't try but could work.

 

As for a 'simple' increment Math function, feel empowered to raise an idea - our PM's are listening 😄

So I ended up taking it a different way. I created a flow variable first, then pulled the value from the u_number_of_reminders field. I incremented it and then set it back into the field. This link below gave me the information to be able to do it.

Flow Variables vs. Scratchpad Variables – snhackery