- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2022 05:16 PM
I would like get the view name from the URL through a catalog script , I have the current script but I'm getting the following error message :
TypeError: Cannot read properties of null (reading 'URL')
function onLoad() {
var view = getParm('view');
if (view.toString() == 'review2') {
g_form.setValue('u_earb_request_type','review2');
g_form.setReadOnly('u_request_name',false);
g_form.setReadOnly('u_assigned_lead',false);
g_form.setReadOnly('u_client_name',false);
}
}
function getParm(value) {
var url = document.URL.parseQuery();
if (url[value]) {
return decodeURI(url[value]);
} else {
return;
}
}
Solved! Go to Solution.
- 1,949 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 12:01 PM
Can you try below code as is in your onLoad script once.
function getParameterValue(name) {
var url = top.location.href;
var value = new URLSearchParams(url).get(name);
if (value) {
return value;
}
if (!value) {
var gUrl = new GlideURL();
gUrl.setFromCurrent();
value = gUrl.getParam("view");
return value; //this will give you the value
if (value.toString() == 'review2') {
g_form.setValue('u_earb_request_type','review2');
g_form.setReadOnly('u_request_name',false);
g_form.setReadOnly('u_assigned_lead',false);
g_form.setReadOnly('u_client_name',false);
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2022 05:39 PM
hi,
Please refer this link
https://community.servicenow.com/community?id=community_question&sys_id=955ffdb3db1e6340656a5583ca96194f
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2022 05:43 PM
I tried this , but got the following error message :
ReferenceError: GlideURL is not defined
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 11:26 AM
Hi Mike,
function onLoad() {
var url = window.location.toString();
var parms = url.toQueryParams();
if (parms["view"] == "review2") {
g_form.setValue('u_earb_request_type','review2');
g_form.setReadOnly('u_request_name',false);
g_form.setReadOnly('u_assigned_lead',false);
g_form.setReadOnly('u_client_name',false);
}
}
Hope this helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2022 11:52 AM