Processing a table

When processing a table, the first that is being processed is the second row, wherein the first row is processed lastly. May I ask what should be the right set up so that the first row should be the first to process. Attached is the screenshot of the settings I followed in Pega Academy and below screenshots is the table and when it is processed.

@LizetteL In my experience, clone collections are not necessarily in screen order, but are in matching order. This is typically from top-to-bottom, but that doesn’t have to be the case depending on how the page adds the rows to the table. If you need to process them in a specific order, then you’ll need to locate some element within each row that indicates its order. In my experience, there is usually some property or inner HTML within the row that differs between rows. At Runtime, you can read this property and then process them in that order. You might need to be creative on this. If you can send the InnerHTML of the table itself (with any non-public data redacted of course), I might be able to see something if you are unable to.

To order the clones, I would keep it rather simplistic. You need to put them in a table so you can sort them. Having them in a table will let you iterate that table in the order they are sorted. I would create a LookupTable with three columns. The “Key” field would be the “Key” property of the row control. The “Sort” field would be whatever the value is you are sorting on. Preferably, this would be a number so as to make sorting easier. I would extract this number from the row and save that for insertion into the table. The last column would be the Row object itself. I would name this column “RowControl”. When defining the fields for the table control, you can specify a type. I would make this, type “OpenSpan.Adapters.Web.WebBase.Controls.Control”. This will hold almost any type of Universal Web Adapter control (definitely a row object).

Now, in your automation you can iterate the Clone collection by passing GetClones into a ListLoop. Within the list loop, you can extract the “Key” property from the row. You will extract the “sort” value by grabbing whatever child or parsing the inner HTML, or by using the Y coordinate of the control possibly. Finally, the “This” property will reference the object itself. With each of these acquired, you can use the AddRecord method of the table to add them to the table. After they are all added, you can sort the table and even iterate it using a TableView.

I would take this in multiple parts to keep things simple. First, identify if there is something you can see with just the data you have about a Row that tells you if it is above or below another row. If you can do that, then the next step is figuring out how to extract that value from the row. Once you have that, then you have all you need to be able to know at Runtime which row is first, next, last, etc.