Call a mircoflow with parameters from Browser back button from a specific page.

Hello Everyone,  I want to call a microflow with parameters on browser back button from a specific page, I tried few ways using javascript snippets, but It’s getting called from back button of other pages too.   For Example:   jQuery(document).ready(function($) {     if (window.history && window.history.pushState) {     window.history.pushState('forward', null, './#forward');     $(window).on('popstate', function() {{         params: {         actionname: "Accounting.TestMF"     } });     });   } });   Any soln would be highly appreciated.  Thanks.
1 answers


$(document).ready(function() {
  // Set up the event listener when the page is loaded

  function setupBackButtonListener() {
    window.history.pushState({ page: "SpecificPage" }, null, "./#forward");

    $(window).on("popstate", function(event) {
      if (event.originalEvent.state && === "SpecificPage") {
        var messageToDisplay = "Welcome back!"; // Replace this with the message you want to display

  function callDisplayMessageMicroflow(message) {{
      params: {
        actionname: "DisplayMessage",
        applyto: "selection",
        guids: ["PLACEHOLDER_GUID"], // Replace "PLACEHOLDER_GUID" with the actual GUID of the object you want to pass as a parameter
        // Assuming your microflow parameter is named "message" of type String
        // If your parameter has a different name or type, adjust this line accordingly
        parameters: {
          "message": message
      callback: function() {
        console.log("Microflow executed successfully");
      error: function(error) {
        console.error("Error executing microflow:", error);

 Add HTML Element:
Now, add a hidden div with the ID "triggerMicroflowOnBack" on the page where you want to trigger the microflow when the back button is pressed:

<div id="triggerMicroflowOnBack" style="display: none;"></div>

Ensure that the jQuery code is included on the specific page where you want to trigger the microflow when the back button is pressed. The jQuery code sets up the event listener on page load, and when the user clicks the browser's back button to return to the specific page, the "DisplayMessage" microflow will be executed, and the specified message ("Welcome back!") will be shown using the "Show Message" action.