Flow Designer - Duration becomes negative for no reason.

mfhaciahmetoglu
Mega Sage

Hi all,

 

I am observing a weird behavior.

 

I have a field on the form called: "Expected Return Date". If the user has not yet returned the item by the expected return date, I have to create a notification. So, I need to wait until the expected return date, then generate the notification.

 

I set up a flow variable and defined as follows:

//Collect end date from User record data pill
var endD = fd_data._1__get_catalog_variables.expected_return_date;

//Instantiate it as a GlideDateTime format
var endDate = new GlideDateTime(endD);

//Get todays date in the same format
var today = new GlideDateTime();

//Collect the difference in time between these 2 dates in miliseconds
var difference = GlideDateTime.subtract(today, endDate);

//Feed the miliseconds into the GlideDuration object
var duration = new GlideDuration(difference);

//return the results
return duration;
 
Then, I put this duration in the Timeout condition of the Wait for Condition.
mfhaciahmetoglu_0-1707146994448.png

 

I observe the following weird behavior.

 

Use-Case-2:

Today: 05-Feb-2024

I choose the expected Return date as 06-Feb-2024.

Flow variable and wait for condition are calculated correctly:

mfhaciahmetoglu_1-1707147138043.png

And:

mfhaciahmetoglu_2-1707147175158.png

 

Use-Case-1:

However, if I choose the date of today -- instead 06-Feb, I choose the same day 05-Feb:

The flow variable seem fine:

mfhaciahmetoglu_3-1707147348941.png

But the duration at the condition becomes negative:

mfhaciahmetoglu_4-1707147388067.png

 

 Anyone has any idea why?

 

Thanks.

Best,

Firat

1 ACCEPTED SOLUTION

mfhaciahmetoglu
Mega Sage

Hi all,

I found a workaround -- checking first if the expected return date is today, then I manually assign 12h, and it works:

mfhaciahmetoglu_0-1707150575587.png

However, why the flow behaves like that is a mystery.

 

Best,

Firat

View solution in original post

1 REPLY 1

mfhaciahmetoglu
Mega Sage

Hi all,

I found a workaround -- checking first if the expected return date is today, then I manually assign 12h, and it works:

mfhaciahmetoglu_0-1707150575587.png

However, why the flow behaves like that is a mystery.

 

Best,

Firat