How to close popup window automatically

ramesh_r
Mega Sage

Hi All,

 

I am showing the Popup window using below catalog client script. My requirement here is the popup window should close automatically in few seconds. Please help me how to close the window automatically 

 

ramesh_r_0-1669867991817.png

 

 

Client script :

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    spModal.open({
        "title": "Tax Validation",
        "message": "Validation is Inprogress, Please wait",
        "buttons": [{
            label: "✘ Understand",
            primary: true
        }],
        "backdrop": "static",
        "keyboard": false

    });
}

 

I have tried this below code but its not working

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    spModal.open({
        "title": "Tax Validation",
        "message": "Validation is Inprogress, Please wait",
        "buttons": [{
            label: "✘ Understand",
            primary: true
        }],
        "backdrop": "static",
        "keyboard": false
    });
  setTimeout(function(spModal) {
             spModal.close();
    }, 500);
}

 

 

2 REPLIES 2

Tuan Vu
Kilo Guru

Try this

spModal.open({
        "title": "Tax Validation",
        "message": "Validation is Inprogress, Please wait",
        "buttons": [{
            label: "✘ Understand",
            primary: true
        }],
        "backdrop": "static",
        "keyboard": false
    })
.then(function() {
   setTimeout(function() {
           spModal.close();
    }, 500);
})

Hi,

 

I tried your code the popup is coming but its not closing automatically.