Creating a loop in Salesforce


I am looking to create a loop in salesforce fo rhte bot to click on the next item in the list, however when the bot clicks out of the item view the list is rearranged please see below screenshot for a better understanding of the problem.

This is the current list of the items

however if i was to click in Paper the list rearranges itself

The loop that i have developed isn’t able to pick up the second item of the list, can anyone help me here?

Use Find children or data extraction to retrieve all the elements. Loop through each element, create a dynamic selector based on the stock level name. use this selector in click activity.
This should resolve the issue.

HI @Madhavi thank you for your response before i go any further with what you have said please see the below screenshot am i doing this right as i havent used find children activity before

Find children activity will return you IEnumerable(UiElement) as output.
You have to use for each to loop through each element and then use click activity to click on each inside the loop.

loop.xaml (13.5 KB)

Is this the way it should be built?

Appreciate your help

I have updated your workflow and also put comments. Please check and update the selectors.
loop.xaml (14.1 KB)

Thank you @Madhavi appreciate that, i have one question however, what do i put in this expression editor?

this is on the first click activity in the loop

You don’t need to specify anything in selector property. I have already specified the value in element property. In an activity, you can either specify selector or Element.


I am looking to get a variable out of salesforce and enter that variable into Amazon however when i and using Get Text or Get Full Text the bot loses the element when it goes to the next item on the list.

This is the selector for the Get Text

The variable is in a table

I am looking for the bot to go into each item and see if more of the item needs to be ordered if it does then the bot is to open Amazon and search for the item to be ordered.

However before i get to that stage the bot is losing the Get Text element when it goes into the second item on the list.

Can anyone help me here?

First thing, don’t use idx property in selector. idx is not reliable.
Please refer your post Creating a loop in Salesforce for the solutions.

Hi @Madhavi I have done what you have asked however the bot is still picking the first item on the list every time.
AmazonLoop.xaml (21.2 KB)
I have attached the file to this response for you consideration.
The loop works perfect first time but when it should be picking the next item on the list it gets confused and stops.



Hi @nick.v,

Please find the updated workflow with my comments.
AmazonLoop.xaml (21.8 KB)