We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

#BLOG: Easy Navigation to List View from Form View in Native UI

Rakesh_M
Mega Sage

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;
    }
}
​

Rakesh_M_0-1782659536533.png

 



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.

2 REPLIES 2

glideFather
Tera Patron

ahoy @Rakesh_M,

 

I haven't tested in my end, so I cannot evaluate the behaviour how it works but the idea in general is very good. :))

 

You can export the update set/xml and attach it here for other users to download to their PDI, eventually you can create this an idea for ServiceNow to implement such a button to the OOTB form.

 

Tip: imagine you have this button available in one instance (client 1) but not in another (client 2), then it is different experience and it can be tricky while you are not allowed to put it to client 2' isntance. For that you can use SN Utils browser extension, press "ctrl/cmd" and field on a form to open a list view in a new window :))

 

_EDIT_ highlighted in orange


✂-----Cutting-out-the---✦AI-noise✦---All-replies-written-and-vouched-for-by-GlideFather---

Rakesh_M
Mega Sage

Hi  @glideFather ,

 

Thanks for the feedback and the suggestions!

I did not consider sharing the UI Action as an XML or submitting it as a product idea—those are great suggestions.I am also not aware of the SN Utils shortcut. That's a handy alternative.

As suggested, I have attached the XML for anyone who would like to try it in their PDI.
You can download it here: Click here 

I'll go ahead and submit this as a Idea as well.

Regards,
Rakesh