Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Redirect URL from dropdown.

Brian Lancaster
Kilo Patron

Hello All,

There was a page created outside of service now.   We want to make it so that if someone picks something specific from a drop down it redirects to our internal internet site.   Is there anyway to do this?

1 ACCEPTED SOLUTION

Brian Lancaster
Kilo Patron

Found my own answer.   Looks like I just need a client script for on change and look for when the variables changes.



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


  if (!isLoading) {


  var reqType = g_form.getValue('request');


  if (reqType == 'Redirect URL') {


  window.open("http://www.google.com");


  window.location = 'home.do';


  }


  }


}


View solution in original post

10 REPLIES 10

Brian Lancaster
Kilo Patron

Found my own answer.   Looks like I just need a client script for on change and look for when the variables changes.



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


  if (!isLoading) {


  var reqType = g_form.getValue('request');


  if (reqType == 'Redirect URL') {


  window.open("http://www.google.com");


  window.location = 'home.do';


  }


  }


}


Hi Brian

I used the mentioned onChange script but without success

Requirements:

If variable (what_would_you_like_to_do) selection changes to 'Create New Catalog Item' then redirect to https://mhsdev.service-now.com/sp?id=sc_cat_item&sys_id=70651f5c1b55141027a8620bbc4bcb92

=====Here is the onChange script I am using=====

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

//Type appropriate comment here, and begin script below
if (newValue == 'Create New Catalog Item'){
var redirectURL = 'https://mhsdev.service-now.com/sp?id=sc_cat_item&sys_id=70651f5c1b55141027a8620bbc4bcb92';
top.window.location = redirectURL ;
}
}

 

see attachment for screenshot

try

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

    //Type appropriate comment here, and begin script below
    if (newValue == 'Create New Catalog Item') {
        top.window.setTimeout(fun2);
    }

    function fun2() {
        top.window.location = "https://mhsdev.service-now.com/sp?id=sc_cat_item&sys_id=70651f5c1b55141027a8620bbc4bcb92";
    }
}

Thanks Mike but earlier I did try that same script to no success.