Back Button in ServiceNow UI Builder?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 05:00 AM - edited 02-15-2024 05:00 AM
Hello everyone,
I'm currently working on a project in ServiceNow UI Builder and I'm in need of some assistance. Specifically, I'm looking to integrate a "back" button functionality into my interface. This button would ideally allow users to navigate back to their previous location within the application.
While I've tried data.record.sysId and context.props.sysId at Link to destination in event but I'm not sure if this is the most effective approach or if there are alternative methods I should consider. If anyone has experience or insights into implementing a "back" button in ServiceNow UI Builder, I would appreciate your help 😄
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-09-2024 12:22 PM
Late to the party here but I recently had a similar requirement.
You can in a browser call "window.history.back()"
The trick was getting access to the window object in UIB, but I found another community article with a way to access it.
So the solution is, create a button, with an event handler that calls a client script.
The client script contains:
function handler({api, event, helpers, imports}) {
helpers.timing.setTimeout(function () {
// this in this context is globalThis, which is equal to window
// this is a workaround to make a basic back button which seems weirdly complicated in UIB
// Accessing the DOM is not always a bad thing.
const previous = this.history.back();
});
}
So clicking the button runs this script, which appears equivalent in functionality to the browser Back button.