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

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

Not sure if it will work on ATF or not, but to go to previous page a simple JavaScript code should work. Client side code

history.back()
-Anurag

Hi Anurag, 

I don't think this will work as this will only take the user back to the most recent page. There is no guarantee that would be the test page. 

Thanks

ALex

This will work same as the browser back button, so im positive it will fulfill the need. 

What I'm not sure is how it will work on ATF. 

Worth a shot though.

 

However, you can try this as well.

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(newIncident);
}

 

-Anurag

-Anurag

Unfortunately, 

Neither of these options worked quite as intended. 

Thanks

Alex