Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Flow designer script error "attempting to use undefined input"

ericgilmore
Tera Guru

Thought this was simple, apparently I'm wrong. Here's the script I'm using. It's supposed to take a string date, change it to a date time object, minus 3 days from it and return the finished product to set a sc_task date field. I have this in an Update Record action.

All it does is not allow my flow to save and return an error. "attempting to use undefined input = 'current' from Flow 1"

/*
**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 rollOnDate = fd_data.trigger.current.roll_on_date;
var dueDate = fd_data.trigger.current.due_date;
var gdt = new GlideDateTime(rollOnDate);
gdt.addDays(-3);
dueDate = gdt.getDate();

return dueDate;

 

Any help appreciated.

1 ACCEPTED SOLUTION

It's basically the same what you are doing here. You are creating a separate action to populate the due date field which can be done inline in your flow with simple 3 lines of code like how i mentioned. 

If you are using the inline Function in the flow to populate a specific field as shown below in picture then you should be using below to call the triggered variables

  • fd_data.trigger.current.variables.roll_on_date, or maybe
  • fd_data.trigger.current.variables.req_item.roll_on_date 

find_real_file.png

If you are creating an action to use it in the flow, you have to define the inputs for the action and access them as inputs.variable_name from the script.

Cheers,

Arsh

find_real_file.png 

View solution in original post

3 REPLIES 3

Arsh2
Tera Guru

Hi Eric,

could you please double check your roll on date field if it starts with u_ if it's a customized field?

I tried the it on my instance and it's working fine. I've created roll on date field on an incident form and applied your logic in the flow designer - it saved and executed as expected. see below

find_real_file.png

 

And when i tested this flow on one of my incident bu giving a roll on date in string format as shown below - it executed the script and applied it to due date field as expected.

 

find_real_file.png

 

Also it might be worth double checking if your "roll on date" field is on the right table you are creating your flow designer for. 

Cheers,

Arsh

find_real_file.png

 

ericgilmore
Tera Guru

@Arsh I was actually passing a variable from a catalog request item. Not one added to the structure of one of the OOTB app form/tables. So, perhaps I should have tried something like:

  • fd_data.trigger.current.variables.roll_on_date, or maybe
  • fd_data.trigger.current.variables.req_item.roll_on_date ??

What I did was just to create a separate action, and call it in the flow.

find_real_file.png

The action, defined

find_real_file.png

find_real_file.png

find_real_file.png

So I didn't actually answer the inlline script question, but I did figure it out. ????

It's basically the same what you are doing here. You are creating a separate action to populate the due date field which can be done inline in your flow with simple 3 lines of code like how i mentioned. 

If you are using the inline Function in the flow to populate a specific field as shown below in picture then you should be using below to call the triggered variables

  • fd_data.trigger.current.variables.roll_on_date, or maybe
  • fd_data.trigger.current.variables.req_item.roll_on_date 

find_real_file.png

If you are creating an action to use it in the flow, you have to define the inputs for the action and access them as inputs.variable_name from the script.

Cheers,

Arsh

find_real_file.png