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

chrisperry
Giga Sage

Hi there,

You could create an onSubmit catalog client script as below:

function onSubmit() {
    //Type appropriate comment here, and begin script below
    if (g_scratchpad.isFormValid) {
        return true;
    }
    var popup = confirm('Are you sure to submit the request?');
    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,

It is working as expected but i want to display the requested for value also in the pop up.  Could you please help me on this.

Do you have a variable to store the Requested for value on your catalog items? I'm not sure what the exact name of it might be, but the below code should work (update requested for variable name if need be):

function onSubmit() {
    //Type appropriate comment here, and begin script below
    if (g_scratchpad.isFormValid) {
        return true;
    }
    var popup = confirm('Are you sure to submit the request ' + g_form.getDisplayBox('requested_for') + '?');
    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,

It is not working as expected.