How to Reload a Page in ServiceNow Service Portal Using a Widget
- davidyang88
- Mar 21
- 3 min read
Updated: Mar 26

Reloading a page dynamically within the ServiceNow Service Portal using a custom widget is a common requirement for many ServiceNow developers and administrators. This capability is particularly useful when certain actions within widgets need to refresh content or reflect updated data on the page.
In this article, we'll explain clearly how you can implement the functionality to reload a Service Portal page when users interact with your custom widgets.
Understanding the Need for Page Reload in Service Portal
When working with ServiceNow’s Service Portal, developers often face scenarios where the page needs to refresh after specific user interactions, such as assigning tasks, submitting forms, or updating records. Typically, widgets perform client-side operations smoothly, but sometimes a complete page reload is essential to display updated data correctly.
For instance, imagine you have a widget that opens a modal dialog for task assignment. Upon clicking the "Assign Task" button, you want the underlying form or page to refresh and immediately display the updated assignment status. Without reloading, the page might show outdated data, leading to confusion and reducing user efficiency.
Implementing Page Reload in Your Service Portal Widget
Let's look at a simple and effective solution to implement a page reload using JavaScript within your Service Portal widget. The recommended and verified method involves using JavaScript's built-in window.location.reload() function.
Step-by-Step Instructions:
Follow these steps to implement the reload functionality effectively in your widget:
Locate the Client Controller of Your Widget: Navigate to your widget's client-side JavaScript section. This is typically located in the widget editor under "Client Script."
Insert the Reload Code: Inside the method triggered by the user interaction (for example, clicking "Assign Task"), add the following line of code:
window.location.reload();
This JavaScript method instructs the browser to refresh the current page immediately after execution.
Example Use Case:
Here's how a simplified widget controller script might look:
function($scope, spUtil) {
$scope.assignTask = function() {
// Your task assignment logic here
// After successful task assignment
window.location.reload();
};
}
In this example, once the "Assign Task" button is clicked and the related business logic completes successfully, the page reloads instantly to reflect the changes.
Alternative Solution:
Another verified approach involves using a timeout to delay the reload, which is beneficial if immediate reload disrupts user experience or if backend processes require some additional processing time:
window.setTimeout(function() {
location.reload(true);
}, 2000); // Reloads the page after 2 seconds
Adjust the time (2000 milliseconds = 2 seconds) according to your specific use case.
Troubleshooting Tips
Browser Console: If the reload doesn't work as expected, use your browser's developer tools (F12) to inspect the console for JavaScript errors. An error elsewhere in your script might prevent the reload from triggering.
Infinite Reload Loop: Be cautious to avoid scenarios where your reload code executes repeatedly, causing an infinite loop. Always ensure your reload logic is wrapped within conditional statements or executed explicitly upon user actions.
Conclusion
Reloading pages dynamically within ServiceNow’s Service Portal using widget interactions significantly enhances the end-user experience by ensuring updated data visibility. By following the simple steps outlined in this article, developers and administrators can easily incorporate reliable page reload functionality into their custom widgets.
As next steps, test your reload functionality thoroughly, consider using delayed reloads for better user experience, and always monitor for JavaScript errors through browser developer tools to ensure seamless portal interactions.