UI action - Return to previous page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 07:15 AM
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.
I'm pretty inexperienced with coding so any help would be great
Thanks
Alex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 07:22 AM
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()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 07:52 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 07:57 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 01:11 AM
Unfortunately,
Neither of these options worked quite as intended.
Thanks
Alex