Are durations in flow designer extremely frustrating, or is it just me?

Jacob Saaby Nie
Tera Contributor

Ok. So this is my usecase:

 

I want to have a functionality in a flow where I read the instance name.

 

  1. If it's a subprod instance, I want to set a duration of 30 seconds.
  2. If it's a production instance, I want to set a duration of 30 days.

This is so I can run actual full tests of flows in subprod instances, without having to manually change back and forth between subprod/prod durations, and incidentally commit short test durations in our production environment.

 

Yes, that has happened 😉

 

So, I thought I could just create a flow variable of type string, then set "d hh:mm:ss" on the Wait for condition action. Nope. That doesn't work. Well, I can assign the datapill, but it won't work.

 

I then tried creating a custom action where I pass two values: One subprod duration and one prod duration.

They're defined as duration type input variables.

I also define a duration type variable as an output variable.

 

So, when I test that custom action, I see that if I set a duration of 10 seconds, the value then becomes a string, and that string will be 1970-01-01 00:00:10. If I set a duration of 30 days, it becomes 1970-01-31 00:00:00.

And when I try to pass that to the duration type output variable, I'm told that it's the wrong type.

 

I've tried two different approaches, as shown below.

 

(function execute(inputs, outputs) {
// ... code ...
})(inputs, outputs);

// Define variables
var devInstance = "dev";
var testInstance = "test";
var sandboxInstance = "sandbox";
var prodInstance = "prod";
var instName = inputs.instanceName;

// Decide if instance is a SUBPROD instance
if (instName == devInstance || instName == testInstance || instName == sandboxInstance) {
    outputs.duration_out = inputs.subprodDuration;
}

// Decide if instance is a PROD instance
else if (instName == prodInstance) {
    outputs.duration_out = outputs.duration_out.add(new GlideDuration(new GlideDateTime(inputs.prodDuration.getValue()).getNumericValue()));
}

 

Why do the duration type formats differ?

Why does my duration type input variable change to a string?

What am I not getting here?

 

AND WHY IS THIS SO UNNECESSARILY FRUSTRATING!?!?!?!?!?!?!?!?

6 REPLIES 6

Mark Manders
Mega Patron

My PDI is sleeping, so I can't do some checks, but why not use system properties? Set your system property on PROD to 30 days (probably need to transform it to seconds or milliseconds, but you can test that) and have it on 30 seconds on pre-PROD. Your flow can stay the same and you can just use whatever you want, because it will always take the correct value.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

That's possibly a great idea Mark, thanks 🙂

Can I use that value in seconds as a Wait for Condition timeout duration? Not "Wait for a duration of time". Not using that.

You probably could, but you may need to do some calculations to get the correct value. The 'wait for condition' action has the duration field. You can use a data pill on that or script it (so you could create a flow variable that gets the property and use it as data pill, or script to the system property in the script field). I think you will need to set it to milli seconds, but it could also be seconds. That's something I never get right the first time 🙂

 

 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

My biggest concern is getting the duration format correct, and actually being able to use it without being told there's a format mismatch because suddenly the platform made it into a string instead of the duration I actually defined it as.