- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2025 02:12 AM
Hello @sanyalshubh
You can pass data between two pages by two method:
Use URL Parameters for small amounts of simple data. This is a quick and effective method for passing data between pages when the data is small and non-sensitive. Example: passing IDs, status, or short strings in the URL query.
window.location.href = "/sp?id=target_page¶m1=value1¶m2=value2";
On the receiving page, use $location.search() to retrieve the parameters:
$scope.param1 = $location.search().param1;
$scope.param2 = $location.search().param2;
Use Session Storage if you need to pass larger or more complex objects. Session storage allows you to store complex data (like JSON objects) temporarily within the browser session. It provides more flexibility and doesn't expose the data in the URL.
sessionStorage.setItem('complexData', JSON.stringify(yourDataObject));
On the receiving page, retrieve the data like this:
var retrievedData = JSON.parse(sessionStorage.getItem('complexData'));Refer: Understanding Session Storage in ServiceNow Widgets: Client and Server-Side Techniques
Hope this helps!
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"
Thank You
Juhi Poddar
Juhi Poddar