How to add pop-up with a button to incident form

rafas_2703
Tera Guru

Hi everyone, 

 

I hope you are doing well.

 

I created a Catalog Item using Maintain items and I have a requirement to add a pop-up with a button based on 2 dropdown values.

What I mean is:

I have 2 select box type variables.


First variable is called dropdown_1 and has the following choices / values:

Other, Functionalities and Access

 

Second variable is called dropdown_2 and has the following choices / values:

Knowledge, Vacations, Breaks

 

How can I, when I choose the option Other from variable 1 and Option Knowledge from variable 2 , make a pop-up with a button redirecting for example to "https://www.servicenow.com/"?

 

Thank you to anyone who can help!

Regards!

 

1 ACCEPTED SOLUTION

rafas_2703
Tera Guru

Hi guys, I have used spModal in my Catalog Client Script to achieve this pop-up and several other funcionalities

View solution in original post

3 REPLIES 3

Dnyaneshwaree
Mega Sage

Hello @rafas_2703 ,

Try below script it might help you if i am able to understand your req:
Create on change catalog client script on your catalog item:

// Catalog Client Script
(function() {
    // This script runs onLoad, onChange, and onSubmit
    function onChange(control, oldValue, newValue, isLoading) {
        // Ensure both dropdowns are selected
        if (!g_form.getValue('dropdown_1') || !g_form.getValue('dropdown_2')) {
            return;
        }

        // Check the conditions for the pop-up
        if (g_form.getValue('dropdown_1') === 'Other' && g_form.getValue('dropdown_2') === 'Knowledge') {
            // Display the pop-up with a redirect button
            var dialog = new GlideDialogWindow("custom_popup");
            dialog.setTitle("Redirect Notice");
            dialog.setBody('<div style="padding: 20px;">You will be redirected to an external site. <button type="button" onclick="window.open(\'https://www.servicenow.com/\', \'_blank\');">Go to ServiceNow</button></div>', false, false);
            dialog.render();
        }
    }

    g_form.onChange('dropdown_1', onChange);
    g_form.onChange('dropdown_2', onChange);
})();

Create new UI page record:

<script type="text/ng-template" id="custom_popup">
    <div style="padding: 20px;">
        <p>You will be redirected to an external site.</p>
        <button type="button" onclick="window.open('https://www.servicenow.com/', '_blank');">Go to ServiceNow</button>
    </div>
</script>

 

Please accept my solution if it works for you and thumps up to mark it as helpful.
Thank you!!

Dnyaneshwaree Satpute
Tera Guru

Hi @Dnyaneshwaree ,

 

Indeed it is helpful but is isn't working. It is not showing any pop-up. I created the onChange Catalog Client Script and add the code to it, as well as the UI Page with the category "Service Catalog" and past the code you gave me to it but nothing happens.

 

Any ideia why?

 

rafas_2703
Tera Guru

Hi guys, I have used spModal in my Catalog Client Script to achieve this pop-up and several other funcionalities