how to check date difference in flow designer script action ?

bala_1312
Tera Contributor

here is the code for workflow "waiting for condition" - 

answer = gs.dateDiff(gs.nowDateTime(), current.variables.u_deactivation_date, true);

 

bhut if i try the same code in flow designer script action  as  below  - 

var now = new GlideDateTime();

 var glideTo = inputs.u_deactivation_date;
    var dur = GlideDateTime.subtract(now, glideTo).getDisplayValue(); //line 3

    var hour = dur.getByFormat('HH'); 

outputs.datdiff = hour;

 

but here for line 3 code i am getting error , can anyoe please help how to calculate that in flowdesigner ?

2 REPLIES 2

Tudor
Tera Guru

Hi,

Could you please explain what you are trying to achieve with this script?

I'm asking because there might be an alternative as you are referring to "wait for condition".

Tudor

 

OlaN
Giga Sage
Giga Sage

Hi,

I wrote a Flow designer tool for date comparison that is free to use a while ago. Use if you like.

Regarding your script, the GlideDateTime.subtract() method requires that you pass it 2 GlideDateTime objects, and currently the second one is probably evaluated as a String, which will generate an error.

To correct, write something like this:

var now = new GlideDateTime();
var glideTo = new GlideDateTime(inputs.u_deactivation_date.toString());
var dur = GlideDateTime.subtract(now, glideTo).getDisplayValue();