Page 1 of 1

Script issue

Posted: 08 Aug 2014 14:29
by sambarlick
Hi guys,

I am working on a flow that has a multiple choice input dialog.

The flow firsts ask a simple yes no question, then no executes the multiple choice dialog.

From the result of the multiple choice dialog i want to change the value of the sleep function.

This is the script that feeds into the sleep function...

if (value == 1)
{
time=2d;
}
if (value == 2)
{
time=3d;
}
if (value == 3)
{
time=4d;
}
if (value == 4)
{
time=5d;
}
else
{
time=1d;
}

I then write time as a variable in the sleep function.

The flow then stops resulting in an error.

What am i doing wrong?

Sam

Re: Script issue

Posted: 08 Aug 2014 17:41
by Martin
Hi,

The values assigned to variable time are wrong, you can either assign the number of milliseconds or a string. I would recommend to use a string in this case, since the duration is very long (note the double quotes):

Code: Select all

if (value == 1)
{
time="2d";
}
if (value == 2)
{
time="3d";
}
...
Be careful with the else on the last if, this will usually make the script assign "1d" to time when you select 1, 2 or 3.

You could also use a list and the variable index to make the script a bit shorter (index is provided by the input dialog 0=first element, 1=second element etc.):

Code: Select all

durations = newList("1d", "2d", "3d", "4d", "5d");
time = getElement(durations, index);
or directly create the time using the selected index in the dialog:

Code: Select all

time = (index + 1) + "d";
The first selected element is at index 0 which would be transformed to "1d".

or set the values of the dialog directly to the values you want to use in the sleep action, for example use the following text in field LIST VALUES of the input dialog action:
1d,2d,3d,4d,5d

Then directly use the inline expression {value} in action Sleep:

Regards,
Martin

Re: Script issue

Posted: 10 Aug 2014 14:32
by sambarlick
Hi Martin,

Unfortunatly those methods didn't work. I have attached the flow, maybe you could see if i have done anything wrong prior to that script.

Much appreciated,
Sam

Re: Script issue

Posted: 12 Aug 2014 16:02
by Martin
Hi Sam,

You are using Multi Choice in the dialog so the user could select multiple values. I did not expect that and I'm not sure how you want to handle the situation when a user selects "No" and "2 Days" at the same time.
You could switch the type of the input dialog to Single Choice or Single Choice Menu and change the script to time = (index+1)+"d";

Regards,
Martin

Re: Script issue

Posted: 12 Aug 2014 21:55
by sambarlick
Thanks Martin,

I can't believe i missed that lol, it makes sense now. No wonder it didn't work.

I then realised i needed a condition at the start to see if the flow was still executing so the flow didn't execute again whilst the sleep was active.

Thanks again!
Sam