For Each loop jump to next activity of entire sequence

Hello. I think the picture says it all. I can’t figure out how to do this.

1 Like

Hi
Use a if condition inside the FOR EACH like this

Counter.Equals(1)

Then it goes to THEN part where you can keep the first Message box

If false it will go to ELSE part where we can keep the second message box

So it will skip accordingly

Cheers @private_matter

in case of loops are limited you can simplify it by following:

Hi. That works if I only have two choices. But what if I have 10 choices. Like in first loop it chooses message1, in 2nd loop it chooses message2, in 3rd loop it chooses message3 up to 10 loops. How do I do this?

but if only message is different we would suggest to setup a part mapping a particular message to loop no

e.g arrMsg = {“msg1”,“msg2”,“msg3” …}
msg = arrMsg(CurrentItem-1)

Handling out of index exceptions we can do:
arrMsg.Skip(CurrentItem - 1).take(1).defaultIfEmpty(“Undefined”).First()
grafik

Hello @ppr
That may be what I’m looking for. I will try it out and provide feedback.

Hi,

FYI, If you want to input the messages to same place, the following might help you.

img20211007-6

Regards,

I tried it and it did nothing. And I don’t want to repeat the same activity more than once. When I run the bot, at the first loop it must choose only Case 1. When it goes back to the while activity on top and runs the same activity 1 and activity 2, it then chooses only Case 2 and runs it once. And so on. If you can send an xaml example, it’ll be great.

Thank you. Yes I want to input the message in the same place. All other activities will be the same. Only 1 single activity will be different. I’ll try your method and see if it works.

I’m getting an error in the message box saying “Message Box: Object reference not set to an instance of an object.” Please download the example I did and see what’s wrong.Quick Testing.xaml (9.3 KB)

@private_matter
find starter help based on ypou xaml here:
Quick Testing_V2.xaml (8.0 KB)

ensure your TypeInto is working and will have a valid selector (otherwise it will use default timeout 30 sec for trying to get the element and will create impression that bot is doing nothing)

Yes it’s working now exactly like I wanted. Thx a lot. I can now continue my work. Just a question. Can you explain how the formula of the string works? Like what you’re defining in it.

"arrMessage.Skip(CurrentItem - 1).take(1).defaultIfEmpty(“Undefined”).First()"

we are taking the array
skip number of elements - Current Item -1 - e.g. Loop=CurrentItem = 2 we skip 1 element
take 1 element - will be our message what we want to take - e.g. Loop=CurrentItem = 2 msg2

in case of we have incomplete filled the message array we will return an default value and ommit the exception: Index out of bounds

(e.g. you increased the repetitions but ommit to add an addtional message to the array)

Alright I see what you mean. Thx for the clarification! :slight_smile:

@private_matter
perfect, just do your final testing and mark solving post as solution afterwards. So others will benefit from it. Thanks

If you have two unique things to do, a While isn’t the appropriate way to do it. Just write to individual step-by-step sets of activities to do each Type Into.

Yes true. I removed the while activity and replaced it with the ‘Repeat number of times’ activity that is wrapped around the entire sequence.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.