How to Dynamically Click the Correct "Work Orders" Link Based on Contractor Name in UiPath?

Hi everyone!

I am working on an automation to select a contractor from a list and then click the corresponding “Work Orders” link dynamically.


Scenario

  • I have 18 contractors displayed in a table UI.
  • Each row contains a contractor name and a “Work Orders” link.
  • The UI structure shows that all “Work Orders” links have the same class (PODetailsHeader) but different tableRow attributes.
  • My goal is to click the correct “Work Orders” link based on the user’s input contractor.

What I Have Tried

1. Dynamically Extracted tableRow for the Contractor

I used the “Get Attribute” activity to extract tableRow from the contractor’s name.

  • Assign Activity:
contractorRow = Get Attribute("tableRow")
  • Issue: Sometimes the extracted tableRow is incorrect or null.

2. Used a Dictionary to Store Contractors and Their Rows

Since I know there are only 18 contractors, I tried using a dictionary to store each contractor’s row manually.

  • Dictionary Setup:
contractorDic = New Dictionary(Of String, String) From {
    {"ACUREN GROUP INC", "1"},
    {"BROCK CANADA INDUSTRIAL LTD.", "2"},
    {"FLINT ENERGY SERVICES", "3"},
    {"METHANEX TEST", "4"},
    {"TETRAD INSULATION SERVICES", "5"}
}
  • Then, I assign the row dynamically:
contractorRow = Convert.ToInt32(contractorDic(contractorName.Trim().ToUpper()))
  • Issue: I keep getting "Value cannot be null" errors when the contractor name doesn’t match exactly.

3. Used a Dynamic Selector for “Click” Activity

Once I obtained contractorRow, I used a dynamic selector in my Click activity.

  • Selector Used:
"<webctrl class='PODetailsHeader' tableRow='" + contractorRow + "' tag='A' innertext='Work Orders'/>"
  • Issue: Even when contractorRow is found, UiPath sometimes does not click the correct link.

4. Tried Using an Anchor, But It’s Not Available in My UiPath Version

I initially planned to anchor the “Work Orders” button to the contractor name, but my UiPath version does not support “Anchor Base” activity.

The picture shows you an idea of the interface

What version of Studio are you using? Since you mentioned Anchor Base, it sounds like you aren’t using modern. You should be, then anchors are built into the selectors. Also, it’s not so much the version of Studio you’re using that matters, it’s the version of UiPath.UIAutomation.Activities.

Usually i prefer dynamic selectors

In your case - Is it not possible to keep dynamic value on the inner text instead of depending on the row

Try capturing the element and open in Ui Explorer to get more insights on the properties of this dynamic element in the table

A screenshot of the table and full properties of the element would help to get more insights

@kflorian

Is table extraction is not working?
if it works you can go with table extraction to extract the links and other columns you want