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-03-2022 01:26 AM
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);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 01:45 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 02:06 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2022 02:17 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2023 12:46 PM
Excellent solution