Pop up window on change of Category variable

Shwetha Nair
Giga Guru

Hi All,

 

I have a requirement to show a pop up window containing two links : Google :https://google.com , SN :https://servicenow.com  on user selecting values as Request Info. , general Inquiry in Category field in one of the Catalog Item . This popup will have a 'X' button & Done button to close the popup in either right side corners respectively. Please find attached for better understanding, expecting a result very close.

 

Thanks,

Shwetha 

1 ACCEPTED SOLUTION

Shwetha Nair
Giga Guru

Apparently, this is how I achieved it using just onchange client script as I found the UI page doesn't support in portal , also GlideDialogWindow was also not supporting in my instance. 

 

Script :

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    if (newValue == 'sysid' ) {
        spModal.open({
            title: "<b>Have you tried the following channels?</b>", // Title of the modal
            message: `
        <ul style="list-style-type: none; padding-left: 0;">
            <li>
                <a href="https://google.com" target="_blank">
                    <img src="Search_Onhover.svg" alt="Google" style="width: 50px; height: auto;">
                    Google
                </a>
            </li>
            <li>
                <a href="https://servicenow.com" target="_blank">
                    <img src="sn_icon.svg" alt="ServiceNow" style="width: 50px; height: auto;">
                    ServiceNow
                </a>
            </li>
        </ul>
    `,
            buttons: [{
                label: "Done",
                action: function() { // Add an action for the button
                    spModal.close(); // Close the modal when "Done" is clicked
                },
             
            }],

        });

    }
}
 
Can add customisations further in message as per requirement.
 
Pop up in portal :
ShwethaNair_0-1740636128474.png

 

 

Hope it helps 🙂

 

Thanks,

Shwetha

View solution in original post

6 REPLIES 6

Dr Atul G- LNG
Tera Patron
Tera Patron

SNOW 🙄 it's SN or ServiceNow.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Ankur Bawiskar
Tera Patron
Tera Patron

@Shwetha Nair 

you can use onChange catalog client script and use modal to show the html content

How to display custom popup while submitting a Service catalog in Service portal 

Glidewindow catalog client script Onload not working on service portal 

Modal Windows in Service Portal

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

hi @Ankur Bawiskar ,

 

This is the first time I am creating a UI page therefore I am facing some issue.

I have created a UI page, but i am unable to call this in onchange client script in my catalog form.

Here is the Ui page :

Name : dialog_window_appsupport

HTML :

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly xmlns:j="jelly:core" xmlns:g="glide">
    <g:ui_form>
        <div class="support-modal">
            <!-- Modal Header with X button to close -->
            <div class="modal-header">
                <span class="close" onclick="closeModal()">×</span>
                <div class="modal-header-content">Choose your support option</div>
            </div>
           
            <!-- Modal Body with hyperlinks -->
            <div class="support-modal-body" style=" width:200px; height:150px;">
                <div class="support-link-group" style="display: flex; flex-direction: column; gap: 15px;">
                    <!-- Link for Google -->
                    <a href="https://google.com" target="_blank" title="Opens in a new tab" class="support-link-anchor-tag">
                        <img role="img" src="Search_Onhover.svg" class="icon-position" alt="Google search" aria-label="Google search" />
                        <span class="support-modal-link" tabindex="0">Google Search</span>
                    </a>
                    <!-- Link for ServiceNow-->
                    <a href="https://servicenow.com" target="_blank" title="Opens in a new tab" class="support-link-anchor-tag">
                        <img role="img" src="sn_icon.svg" class="icon-position" alt="ServiceNow" aria-label="ServiceNow" />
                        <span class="support-modal-link" tabindex="0">ServiceNow</span>
                    </a>
                </div>
            </div>

            <!-- Modal Footer with Done button -->
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" onclick="closeModal()">Done</button>
            </div>
        </div>
    </g:ui_form>

    <!-- JavaScript to handle modal behavior -->
    <script>
        function closeModal() {
            // Close the modal by hiding it (or any other logic to hide it)
            var modal = document.querySelector('.support-modal');
            modal.style.display = 'none';
        }
    </script>
</j:jelly>
 
Can you help me with Client side code to call the UI page, 

@Shwetha Nair 

if you are using native then you can use GlideDialogWindow() to call the UI page

var dialog = new GlideDialogWindow("dialog_window_appsupport"); // give ui page name here
dialog.setSize(750,1200);
dialog.setTitle("Support Options");
dialog.render();

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader