I want a new website to open after clicking a checkbox variable

Kishore47
Tera Contributor

Hello everyone,

In Service Catalog, I want a new website to open after clicking a checkbox variable. How can I achieve this?

Thanks in advance.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Kishore47 

you can use onChange catalog client script and open the URL in new tab

this will work in both native and portal

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    try {
        if (window == null) // portal
        {
            var url = ''; // your website
            top.window.open(url, "_blank");
        }
    } catch (ex) {
        var url = ''; // your website
        g_navigation.open(url, '_blank');
    }
}

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

View solution in original post

2 REPLIES 2

Vishal Jaswal
Giga Sage

Hello @Kishore47 

 

You need to develop an onChange Catalog Client script as shown below:

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}

// Replace with your website URL here
var websiteURL = "https://www.google.com";

if (newValue == 'true') {
window.open(websiteURL, '_blank');
}
}


Hope that helps!

Ankur Bawiskar
Tera Patron
Tera Patron

@Kishore47 

you can use onChange catalog client script and open the URL in new tab

this will work in both native and portal

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue == '') {
        return;
    }
    try {
        if (window == null) // portal
        {
            var url = ''; // your website
            top.window.open(url, "_blank");
        }
    } catch (ex) {
        var url = ''; // your website
        g_navigation.open(url, '_blank');
    }
}

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