Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

How to get Query String in Client scripts

prasad48
Tera Guru

How to get QueryString values in clients script. I am looking for a way to write code to work for Service Portal   and also native service now

6 REPLIES 6

oharel
Kilo Sage

That depends on what you are trying to achieve.



A normal query can be something like:


var r = g_form.getValue('thisField');


var q = new GlideRecord('thisTable');


q.addQuery('field1', r);


q.query();


while(q.next()) {


//do something


}



If you explain in a bit more details and give examples we can help more.


harel


I have requirement like, Selecting the dropdown   value on load client script



Below is my url


https://test.service-now.com/hrsp?id=list&dataid=123



I need to catch the "dataid" values in client script and   based on the dataid value , i need to fill other values on the from.


The URL is not reachable, but you can post a screenshot.



So you need something like this:


function onLoad() {


    //Type appropriate comment here, and begin script below



  var data = g_form.getValue('dataid');


  if(data == 'someData') {


  g_form.setValue('Field1', 'someValue1');


  g_form.setValue('Field2', 'someValue2');


  g_form.setValue('Field3', 'someValue3');


  }


   


}



harel


I need something like this only. But "dataid " i need to read from the URL.not from the form.