Eliminating Redundant Success Messages on Page Refresh

In this brief guide, we’ll cover how to prevent success messages from reappearing each time a user refreshes the page.

Understanding the Issue

For those using an older version of APEX, this is a familiar challenge. When a process successfully completes, a success message is displayed. However, if users refresh the page—either by pressing F5 or clicking the refresh button—this message shows up again. This happens because the URL contains a success_msg parameter, which triggers the notification every time the page reloads.

The Solution: Remove the Success Message Parameter

To stop the success message from displaying repeatedly, you can eliminate the success_msg parameter from the URL with a simple JavaScript code snippet.

  1. Access Your APEX Workspace: Go to the specific page where your process is configured.
  2. Insert the JavaScript Function: Add the following code to your global functions
function _removeParam(key, sourceURL) {
   var url = new URL(sourceURL);
   url.searchParams.delete(key);
   return url.toString();
}
  1. Implement on Page Load: Next, place this snippet to remove the parameter when the page loads
window.history.pushState(null, null, _removeParam("success_msg", window.location.href));

Once you’ve implemented these changes, try submitting the page and refreshing it. The success message should no longer appear!

Consider applying this code at the application level within your page template for a more comprehensive solution. This way, you can utilize it across multiple pages. We’ll dive into that topic in a future tip!