UI action - Return to previous page

Alex319
Giga Guru

Hi All, 

I am trying to create a UI action which works with ATFs. This UI action will be used when on the test results page as a one click way of getting back to the related test. 

So far I have managed to get the button navigate back to your last updated record. However, if this wasn't the test then it will take you to the wrong page. Additionally, I believe if you are testing an ATF which wasn't updated by the person clicking the button then it doesn't work so well. 

Below is the code I have used:

var relatedTest = new GlideRecord("sys_atf_test");
relatedTest.addQuery("sys_updated_by","=",gs.getUserName());
relatedTest.orderByDesc("sys_updated_on");
relatedTest.query();
if (relatedTest.next()) {
action.setReturnURL(current);
}

I am trying to navigate from Test results to the matching Test record. 

find_real_file.png

find_real_file.png

I'm pretty inexperienced with coding so any help would be great

Thanks

Alex

9 REPLIES 9

Try this

var relatedTest = new GlideRecord("sys_atf_test");
relatedTest.addQuery("sys_updated_by","=",gs.getUserName());
relatedTest.orderByDesc("sys_updated_on");
relatedTest.query();
if (relatedTest.next()) {
   action.setRedirectURL(relatedTest);
}
-Anurag

I tried this a little earlier. It does work a bit better as it will always return the user to an ATF test. However, it returns the user to the last atf they updated. 

If i run a test that was updated by a different user then this doesn't work. 

It might need to use a variable such as start date instead of updated by. 

Thanks

Alex

So you just need to refine your query here. It will go to the record you pass, you just need to get to the right record.

 

-Anurag

Yeah that's what i'm trying to figure out. There is quite limited options within ATFs when you look at the XML. 

I think I can use start time and then need to figure out how to filter by that time. 

Do you know if you can orderByDate? 

Thanks

Alex

Excellent solution