The CreatorCon Call for Content is officially open! Get started here.

Add Link to variable selectbox in serviceportal

jess1245
Tera Contributor

Hi, 

I want to achieve that in the ServicePortal, when a new request is made and the variable “xy” is selected in a select box, the user is automatically redirected to a page specified in the client script. I have already written the code for this, but a JavaScript browser error keeps occurring.


function onChange(control, oldValue, newValue, isLoading) {

    if (isLoading || newValue == '') {

        return;

    }

    // Überprüfe, ob die ausgewählte Variable den gewünschten Wert hat

    if (g_form.getValue("select_the_reason_for_the_external_user_request") == 'teams_sharepoint') {

var url = 'www.test.com'

    window.open(url, '_blank');

 

        // Leite den Benutzer auf die gewünschte Seite weiter

        openNewTab();

    } else if (g_form.getValue("select_the_reason_for_the_external_user_request") == 'other_assap') {

        // Führe die Catalog UI Policies show variable durch

        g_form.setDisplay('show variable', true);

    }

}

Thanks and BR 
Jessica 

 

1 REPLY 1

Amit Verma
Kilo Patron
Kilo Patron

Hi @jess1245 

 

You can refer below post and give it a retry. Ensure that you set Isolate Script to false as this requires DOM Manipulation.

https://www.servicenow.com/community/developer-forum/redirect-users-to-a-url-based-on-variable-selec...

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.