Flow Designer: How do you update a date/time field to the current date and time?

adeh
Tera Contributor

I have just started to look at the new Flow Designer in Kingston. I wanted to set up an action to update a date/time field on the form to the current date and time, but can't see how you can do this. The flow designer wants you to input an actual date and time, which obviously is fixed. How can I workaround this?

7 REPLIES 7

There is no facility to add script in Flow Designer, unlike the older Workflow Designer.

maynartt
Kilo Guru

From my instance's Stats page:

Build name: Kingston
Build date: 04-25-2018_0907
Build tag: glide-kingston-10-17-2017__patch3b-03-28-2018

Please note that gs.nowDateTime() is not working for me.  Following best practice, I have put my flow into a scoped app (I'm guessing the successful execution noted above was in Global).  I then get this error when executing:

Background message, type:error, message: Function nowDateTime is not allowed in scope x_maim2_flowtracer. Use GlideDateTime instead: new GlideDateTime().getDisplayValue()

Then, when I try to use as recommended, I get this error:

Access to class com.glide.glideobject.GlideDateTime denied because it is not allowed in sandbox

next step is to build a separate script include within same scoped app.  I'll post if it works.  In the meantime, anyone have any other suggestions?

maynartt
Kilo Guru

sorry - missed the note from above where indicated "gs.nowDateTime() is probably not accessible in an application scope".  

implemented a relatively simple work-around.  just created a new action in same scoped app in flow designer that just returns the current date time.

Action has no Inputs.

Has just one Script step, with no Input Variables, the following Script:

(function execute(inputs, outputs) {
var currentDateTime = new GlideDateTime().getDisplayValue();
outputs.cDateTime = currentDateTime;
})(inputs, outputs);

and the single Output Variable is:

cDateTime, type String.

Outputs Name is cdatetime, and value is stepâž›Script stepâž›cDateTime

Then inserted this action in my flow above the action where I need to populate a datetime field with the current date time, and dragged its pill into the target field.