Skip to main content
Question

How to Dynamically Select a Row in a Web Table Based on a Specific Value?


Forum|alt.badge.img+3


Hello everyone,

I am automating a process in Automation Anywhere where I need to identify and reject an invoice on a web portal. The invoice to be rejected is identified using the amount, which I compare with a value extracted from an XML file.

🔹 Scenario:

  • The table on the web portal displays multiple invoices with columns like "Reference Invoice," "SAP Account," "Amount," etc.
  • Once I identify the correct row based on the amount, I need to:
    1. Select the checkbox for that invoice.
    2. Enter the rejection reason in the corresponding text field.

🔹 Problem:

  • I am struggling to dynamically select the checkbox and input field without selecting the wrong invoice.

 

🔹 Question:
What would be the best strategy to correctly select the checkbox and enter the rejection reason in the row that contains the correct amount?

I appreciate any suggestions or experiences you can share.

Thanks! 🚀
 

 

6 replies

Aaron.Gleason
Automation Anywhere Team
Forum|alt.badge.img+10
  • Automation Anywhere Team
  • 539 replies
  • March 26, 2025

You will need to determine the indices of the checkbox and textarea, and how that index is incremented.

To do this, capture the first checkbox with a Recorder: Capture. Note the DOMXPATH. Then capture the second checkbox and note the DOMXPATH. Determine the difference. Usually, it’s one number that increments. That index is how you can point to each of the checkboxes.

Sometimes the index increments by one, sometimes by another value, so watch carefully. It also may start at one, two, or any number.

When working with a dynamic DOMXPATH (that is, a DOMXPATH that has a variable for one of the indices), you will likely have to disable the PATH of the object in the properties. Conversely, you can dynamically address the PATH, but if you do, you will need to disable the DOMXPATH.

Your DOMXPATH may look something like this:

//TABLE[0]/TR[$nMyIndex.Number:ToString$]/TD[1]/INPUT[0]

Notice how the number variable is replacing one of the static indices. In this case, the TR (table row). Also notice you must cast the number variable as a string.


Forum|alt.badge.img+3
  • Author
  • Cadet | Tier 2
  • 2 replies
  • March 26, 2025

 

Hello everyone,

I followed the suggested approach:

  • I captured the checkboxes and rejection fields, analyzed their DOMXPath, and identified the index pattern.
  • I created a dynamic DOMXPath using a variable for the row index.
  • I disabled the Path and kept DOMXPath enabled.

However, the bot is still not selecting the correct field for rejection. It seems like the selection does not align with the expected row.

Is there another step I might be missing? Should I handle the index differently?

Any additional guidance would be greatly appreciated!

Thanks in advance.


Lu.Hunnicutt
Pathfinder Community Team
Forum|alt.badge.img+11
  • Pathfinder Community Team
  • 66 replies
  • March 26, 2025

@Aaron.Gleason 
@Shreya.Kumar 

@Vatsy 

@Dineshkumar Muthu ​

Tagging some folks who may be able to further support with this.


Dineshkumar Muthu
Navigator | Tier 3
Forum|alt.badge.img+9

Hi ​@luis.espeleta ,

 

To dynamically select a row in a web table based on a specific value in Automation Anywhere A360, you can follow these steps:

 

1. Capture the Web Table: Use the "Capture" action to identify the web table on the portal. Ensure you capture the table's structure and properties.

 

2. Loop Through Rows: Use the "Loop" action to iterate through each row in the table. You can set the loop to go through all rows dynamically.

 

3. Extract Data: Within the loop, extract the value from the "Amount" column for each row. Use the "Get Property" action to retrieve the text or value of the cell.

 

4. Compare Values: Use an "If" condition to compare the extracted value with the amount from your XML file. Ensure the comparison accounts for formatting differences (e.g., currency symbols).

 

5. Select Checkbox: If the values match, use the "Click" action to select the checkbox in the corresponding row. You can dynamically construct the DOM XPath or CSS selector for the checkbox based on the row index.

 

6. Enter Rejection Reason: Similarly, use the "Set Text" action to input the rejection reason in the text field for the same row. Again, dynamically construct the selector for the text field.

 

7. Break the Loop: Once the correct row is found and actions are performed, you can use the "Break" action to exit the loop.

 


Vatsy
Pathfinder Advocate | Tier 6
Forum|alt.badge.img+14
  • Pathfinder Advocate | Tier 6
  • 107 replies
  • March 27, 2025

Thanks for the tag ​@Lu.Hunnicutt!

Hi ​@luis.espeleta,
The solutions provided by ​@Aaron.Gleason and ​@Dineshkumar Muthu above looks good but I also wanted to suggest you that if there is a search box available in the web page where the table exists, you can search for the relevant Reference Number (Ex. 3C9E4) so that there is only one entry left in the table as the search result. You will then have only one unique entry to select the checkbox for which will reduce the additional logic that you currently require to select the required checkbox.


Aaron.Gleason
Automation Anywhere Team
Forum|alt.badge.img+10
  • Automation Anywhere Team
  • 539 replies
  • March 27, 2025

@luis.espeleta The index of items in HTML starts at an index of 1. The first row of a table is row 1. The first column is column 1. 

That’s pretty clear for a table, but for other constructs like <span> or <div>, the patterns can be obscured. One of my co-workers even mentioned that his index started at 3 and incremented by 3!

It will just take some experimentation. Build some small test bots -- don’t try and debug in a production bot. Start with a simple bot that clicks all the checkboxes or puts a value in all the textareas.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings