How to make portal.show event fire on other portals

Question / Problem

I am using portal.show event in the system wide JavaScript customization. But this event only works on the default portal. When I move to my second or third portal, event does not fire. If I go back to my default portal, event fires.

Is there any way to make this event fire on other portals too?

Code / Attempts

I used this simple code just to check when the event fires (it shows a dialog):

(function () {

  "use strict";

  kintone.events.on("portal.show", async () => {

    const result = await kintone.showConfirmDialog({

      title: 'Popup',

      body: 'JavaScript initiated',

      showOkButton: true,

      okButtonText: 'OK',

      showCloseButton: true

    });

  });

})();

A dialog appears when portal event fires.

Desired Outcome / Expected Behavior

I want dialog to appear when other portals are shown too.

If there is also a way to know which portal triggered the event (portal2, portal3 etc), that would also be helpful.

Hello @zebra_taxi

If by your second and third portals you mean the Portal pages of different Spaces, you will need to use a different event.

portal.show is the event for the main Kintone Portal. For a Space Portal, use:

space.portal.show

Could you try using this event and see if it works for your Space Portals?

Thank you.