Find row number of current object and pass it to another object

Hoping someone can help with this.
I have a table of users with 9 columns (Username | First Name | Last Name | Employee Number | Active Date | Inactive Date | Status | Delete | Reset Password.
I need to find the row that contains a certain username and then update the XPath of the delete button object so that I can click the correct one.

I match the Object User on:
tag = a
text contains UserName
I can’t match on href or ID as these are dynamic (i.e. /Account/Delete/0a99cb8e-8891-41d9-8e65-c082313f6c2c)

Currently this object would also match the Xpath:


However the tr[249] value will change depending on how many other users are in the table so I can’t rely on it.

I would like to extract the tr value from the XPath of the found object and save it in a variable so I can pass it into the Xpath of the Delete User object.
Currently the manual Xpath is:


which I guess I can change like so:

user_row = 0
TestObject to = findTestObject('Page_Users/a_Edit User', [('text') : GlobalVariable.G_User])
to.findPropertyValue('xpath')."a_Delete User" = WebUI.modifyObjectProperty(to, 'xpath', 'equals', ('//*[@id="grid"]/table/tbody/tr[' + 
    user_row) + ']/td[8]/a', false)

Just struggling with finding and extracting the correct value so I can assign to user_row.

WebUI.modifyObjectProperty will return to you a new Test Object as an output, so this assignment is not correct:

to.findPropertyValue('xpath')."a_Delete User" = WebUI.modifyObjectProperty(to, 'xpath', 'equals', ('//*[@id="grid"]/table/tbody/tr[' + 
    user_row) + ']/td[8]/a', false)It should be:TestObject changedTestObject = WebUI.modifyObjectProperty(to, 'xpath', 'equals', ('//*[@id="grid"]/table/tbody/tr[' +  user_row) + ']/td[8]/a', false)

Thanks for that… still stuck on actually getting the attribute though.
I’ve tried adding the parameter P_Username to the object and passing through the variable V_Username and this allows me to scroll to the correct line using:

WebUI.scrollToElement(findTestObject('Page_Users/a_Edit User', [('P_Username') : V_Username]), GlobalVariable.G_Timeout)

I still need to either get the index of the object, extract the tr value or do a count so that I can set and use the user_row variable.

I’ve tried to extract the tr value using getAttribute:

user_row = WebUI.getAttribute(findTestObject('Page_Users/a_Edit User', [('P_Username') : V_Username]), 'tr')

This just returns null