How to get Query String in Client scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2017 11:48 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2017 12:12 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2017 12:22 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2017 12:48 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-23-2017 12:50 PM
I need something like this only. But "dataid " i need to read from the URL.not from the form.