How to display a confirmation Pop up in Service Portal

Arun87
Giga Contributor

Hi Team,

  We have a catalog item and user will be filling the details in the catalog item form in service portal. While user is submitting the request it should display the message stating "Are you sure to submit the request: requested for" and it should contain ok and cancel button. If user is selecting ok it should submit the request. If user is selecting cancel then it should be in the same page. Kindly help me to achieve this,

 

19 REPLIES 19

Hi Arun,

Please try below onSubmit catalog client script instead, it should work:

function onSubmit() {
    g_form.getReference('requested_for', doPopup);
}

function doPopup(reqFor) {
    if (g_scratchpad.isFormValid) {
        return true;
    }
    var popup = confirm('Are you sure to submit the request ' + reqFor.getValue('name') + '?');
    if (!popup) {
        g_scratchpad.isFormValid = false;
        return false;
    } else {
        g_scratchpad.isFormValid = true;
        g_form.submit(g_form.getActionName());
        return false;
    }
}

If this answer is helpful please mark correct and helpful!

Regards,

Christopher Perry

If this answer is helpful please mark correct and helpful!

Regards,
Chris Perry

Hi Chris,

  We are getting pop up and also it is displaying the requested for in the popup also. But when we are clicking on the cancel button it is also submitting the request. It should not allow to submit the request if we are clicking on cancel button. It should allow to submit the request if we are clicking on OK button

 

Ok that is good it is getting closer. Let's try simplifying the script a little bit -- can you try the below?

Also, I would really appreciate it if you would mark my answers as helpful and/or correct!

function onSubmit() {
    g_form.getReference('requested_for', doPopup);
}

function doPopup(reqFor) {
    var popup = confirm('Are you sure to submit the request ' + reqFor.getValue('name') + '?');
    if (!popup) {
        return false;
    } else {
        return true;
    }
}

If this answer is helpful please mark correct and helpful!

Regards,

Christopher Perry

If this answer is helpful please mark correct and helpful!

Regards,
Chris Perry

Hi Chris,

I have tried but still it is allowing me to submit the ticket.

Ok please update script as below and reply with results:

function onSubmit() {
    g_form.getReference('requested_for', doPopup);
}

function doPopup(reqFor) {
    var popup = confirm('Are you sure to submit the request ' + reqFor.getValue('name') + '?');
    alert('popup val is: ' + popup);
    if (!popup) {
        return false;
    } else {
        return false;
    }
}

Also, I would really appreciate it if you would mark my answers as helpful and/or correct!

If this answer is helpful please mark correct and helpful!

Regards,

Christopher Perry

If this answer is helpful please mark correct and helpful!

Regards,
Chris Perry