In Pega – How to close Modal Pop up Forcefully, Cancel the case and Redirect to Harness Landing Page

Share with Love

I’m having a problem with a Pega application. When I’m in a stage and perform actions, then click “Cancel,” a popup appears with “Unsaved changes” and “Cancel” and “OK” buttons. My goal is for the “OK” button to redirect to the homepage.

I’ve configured the “OK” button action to be a “Landing Page” display, specifying the appropriate Name, Class, and Harness Name. I also have a separate “Cancel” action.

However, when I click “OK,” the popup doesn’t close, and the landing page appears behind the current case (within the pre-built case’s frame, I presume). The popup remains open, blocking interaction with the landing page.

How can I resolve this issue so that clicking “OK” closes the popup and redirects the user to the specified landing page?

Updated JavaScript Function

function closeModalCancelCaseAndNavigate(harnessClass, harnessName) {
// Close the Pega modal window
if (typeof pega !== "undefined" && pega.u && pega.u.d && pega.u.d.hideModalWindow)
{
pega.u.d.hideModalWindow();
}
// Cancel the case (this triggers the case cancellation)
if (typeof pega !== "undefined" && pega.processEngine && pega.processEngine.cancelFlow)
{
pega.processEngine.cancelFlow();
}
// Redirect to the specified harness (Landing Page)
pega.desktop.showHarness({
className: harnessClass,
harnessName: harnessName
});
}

How to Use in Pega Action:

  • In the OK button actions, add:
    1. Run Script
      • Function Name: closeModalCancelCaseAndNavigate
      • Parameters:
        • "YourClassName" (replace with actual class name)
        • "YourHarnessName" (replace with actual harness name)

Alternative Approach (Using Only Run Script in Action)

If you prefer not to create a separate script file, you can directly add this in the Run Script action:

pega.u.d.hideModalWindow();
pega.processEngine.cancelFlow();
pega.desktop.showHarness({
className: "YourClassName",
harnessName: "YourHarnessName"
});

This ensures: ✅ Modal Closes
Case Cancels
Redirects to Landing Page

Let me know if you need further adjustments!

By Admin

Sam is the founder and editor of TheGuestBlogging.com. With over 10 years of experience in website development, WordPress, SEO, and digital marketing, he helps businesses, bloggers, and website owners grow their online presence through content marketing and search engine optimization. I regularly writes about blogging, guest posting, technology, entertainment, and online business trends. My goal is to provide accurate, helpful, and up-to-date information that helps readers make informed decisions.

View All Posts

Related Posts