Popup catalog client script with buttons

Community Alums
Not applicable

Hi,

I need to create an onLoad catalog client script on my catalog item that will pop up a message:

"do you want to continue?"

and under will be two buttons:

"Yes" and "No"

If the user will click on 'Yes' the pop up will be closed and he will stay at the same page.

If he will click 'No' then he needs to redirect to Service Portal homepage

5 REPLIES 5

Kieran3
Tera Expert

Hi @Community Alums 

 

What is the use case for this? To load a catalog item and immediately be asked if you want to continue isn't a great User Experience. 

frviuf
Tera Sage

Hi @Community Alums,

This script opens a spModal onLoad:

The property noDismiss hides the header and prevents the popup from being closed from the X corner button.

function onLoad() {

    spModal.open({
        title: "Do you want to continue?",
        message: "Do you want to continue?",
        buttons: [
            { label: "Yes", primary: true },
            { label: "No", cancel: true }
        ],
        backdrop: "static",
        keyboard: false,
        noDismiss: true
    })
    .then(
        function() {
            // YES clicked
        },
        function() {
            // NO clicked
            var redirectURL = '/sp';
            top.window.location = redirectURL;
        }
    );

}

 

Community Alums
Not applicable

@frviuf the problem with this solution is that if the user click 'No', then before being redirected to sp he get asked again if he wants to leave without saving the changes, is there any way to prevent that message?

agrod_0-1764742807102.png

 




Community Alums
Not applicable