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
Script issue
Moderator: Martin
Re: Script issue
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):
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.):
or directly create the time using the selected index in the dialog:
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
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";
}
...
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);
Code: Select all
time = (index + 1) + "d";
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
-
- Posts: 96
- Joined: 27 Jul 2014 10:40
Re: Script issue
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
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
- Attachments
-
- flow_Migraine_20140811_002937.xml
- (8.03 KiB) Downloaded 647 times
Re: Script issue
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
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
-
- Posts: 96
- Joined: 27 Jul 2014 10:40
Re: Script issue
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
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