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.

URL field in client script

maneesh3
Tera Contributor

Hi,

I have an URL field, and need to set that field value in ONLOAD client script, where it will combination of 2 fields values in the form:

 

like below:  http://Current FIELD1 value + /xyz. + Current FIELD 2 value. 

 

Please help me with the script.

Thanks for the help!!!

 

 

 

 

 

1 ACCEPTED SOLUTION

Ahmmed Ali
Giga Sage
Giga Sage

Hello,

 

below is onload script.

 

rename fields names with your field names.

function onLoad() {
//Type appropriate comment here, and begin script below

var f1 = g_form.getValue("u_title");
var f2 = g_form.getValue("u_description");

g_form.setValue("u_url","http://"+f1+"/xyz"+f2);

}

 

Thanks,

Ali

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

View solution in original post

2 REPLIES 2

Ahmmed Ali
Giga Sage
Giga Sage

Hello,

 

below is onload script.

 

rename fields names with your field names.

function onLoad() {
//Type appropriate comment here, and begin script below

var f1 = g_form.getValue("u_title");
var f2 = g_form.getValue("u_description");

g_form.setValue("u_url","http://"+f1+"/xyz"+f2);

}

 

Thanks,

Ali

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

i really doubt if the values would remain same after every time the form loads.

 

Ill rather suggest to create a UI policy and use the filter field 1 changes or field 2 changes, and rather  UNselect the ui policy runs on load.

in execute if true:

 

var f1 = g_form.getValue("field1");
var f2 = g_form.getValue("field2");

 

var str= "http://"+f1+"/xyz"+f2;

g_form.clearValue('u_url');
g_form.setValue("u_url",str);