#BLOG: Easy Navigation to List View from Form View in Native UI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hello Community,
During development and testing in ServiceNow, it's common to have multiple records open across different browser tabs. When you open a record from a list, the browser's Back button returns you to that list only if the previous page in the current tab is the list view. If the record was opened from another page or another tab, clicking Back navigates to the previous page in the browser history instead of the table's list view.
To simplify navigation, I created a simple UI Action that always takes the user back to the current table's list view.
Approach:
- Check whether the previous page is the current table's list view.
- If it is, redirect the user back to that exact page.
- Otherwise, fall back to the default list view.
Implementation:
1. Create a new UI Action.
2. Configure the following fields:
- Name: List
- Table: Global
- Show insert: True
- Show update: True
- Client: True
- Onclick: goToList()
- Isolate script: false
- Form button: True
3. Add the following script to the Script field.
function goToList() {
// Default list URL for the current table
var listUrl = g_form.getTableName() + "_list.do";
// Return to the previous list page if available
if (document.referrer &&
document.referrer.indexOf(listUrl) !== -1) {
window.location.href = document.referrer;
} else {
// Otherwise, open the default list view
window.location.href = listUrl;
}
}
I'd be interested to hear how others handle this scenario. If you've implemented a similar solution or know of a different approach, please share your thoughts.