Repeat number of times string not working

Hello. I have added a repeat number of times activity inside a Use Application/Browser activity. Instead of the CurrentItem Int32 variable, I added a new string variable called Services in the For each field. I then added a switch activity in the body with the expression set to Services.ToString and added all string key cases by names instead of numbers for easy identification.

Repeat number of times is set to 13 and starts at 1.

However, when I run the activity, it simply skips the entire switch. What am I doing wrong?

@private_matter its before the xondition is not meeting any case…

For example if you create a case “a”,case “b”

Then you need to give switch(a) to execute the case “a”

Refer to the below doc. Also make sure you are propery setting the argument type based on the requirement.

Kindly show us a snap please @private_matter

Hi @private_matter

What does services variable contain?

It contains nothing is just a string.

1 Like

Hey @private_matter

Can you print Services which is passed in the case expression!

The case value should be exactly similar !

Thanks
#nK

Well what should I use then?

Please show the value by printing let’s check !

i’m not understanding what u mean by printing

Just print the services in a log inside loop !

I’m still not getting it. Please provide an example.

Add a Log Message activity before the Switch, and put Services in it so it’ll spit out what the value of Services is.

Or you could set a breakpoint on the Switch, run in Debug, and see the value during runtime.

You don’t need .ToString if Services is a string variable.

The point here is that Services must not have a value that matches any of the Cases. That’s why none of the Cases are executed.

1 Like

If Services contains nothing then how would you expect it to run one of the Cases?

A Switch executes the Case that has the value that matches the expression. If Services doesn’t have a value then no Case will match.

So should I have the Services set to an array of strings and add the string names exactly as they are in the Cases names? Is that what you’re saying?

Yes that is a good way to do it. But then you don’t use Retry. You’d use a For Each to iterate over the Services array.

Also, you don’t even really need an array variable. You could just put the list right into the For Each:

image

Alright, that’s good. But how can this be done using the repeat number of times activity?

Why would you need the Repeat activity? That’s the wrong activity to use. Set up your array and use it in For Each. If there are 5 items in the array it’ll loop 5 times. If there are 50 items in the array it’ll loop 50 times.