- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2022 04:27 AM
Hello All,
I am trying to decode a URL, but due to the special character "&", the url is not coming back as expected.
url that has to comeback: com.glideapp.servicecatalog_cat_item_view.do?sysparm_id=342dc43a60d929007c9ff3c5c6f68fcf&sysparm_filter=assignment_group=da73fd09db2963001fafd0c0ce961951^state=1^assigned_to=d8d103f4c8722500ceb1e6aedf04ae98^last_found<javascript:gs.dateGenerate('2022-08-04','start')&sysparm_vulid=&sysparm_filtertype=defined
In the above link, in the sys_param_filter because of the highlighted portion, the url is not taking the entire filter, the url is taking until last found and the other conditions in the filter is being ignore, which results in the issue of list of the records. How to deal with this issue. used below code.
Please help me on this. Thanks
Below is my code. the filter value is not working as expected when ever we use greater or less than in the filter.
function onLoad() {
//Populate the variables with the parameters passed in the URL
//Use the 'getParmVal' function below to get the parameter values from the URL
var filterV = getParmVal('sysparm_filter');
var filterTypeV = getParmVal('sysparm_filtertype');
var vulV = getParmVal('sysparm_vulid');
if(filterV){
g_form.setValue('u_vulnerability_filter',filterV);
}
if(vulV){
g_form.setValue('u_vulnerable_ids',vulV);
}
if(filterTypeV){
g_form.setValue('u_filter_type',filterTypeV);
}
}
function getParmVal(name){
var url = document.URL.parseQuery();
if(url[name]){
return decodeURI(url[name]);
}
else{
return;
}
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2022 05:05 AM
Hello Mahendra,
I got this issue resolved. The filter which I am using in this client script is being rendered from a UI Page. I had to add a condition as below in that script
var queryF = request.getParameter("query_filter").toString();
if (queryF.includes("&lt") || (queryF.includes(">"))) {
queryF = queryF.replace("&lt;", "<");
queryF = queryF.replace(">", ">");
}
Thanks for your script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2022 04:42 AM
Maybe try following
function onLoad() {
//Populate the variables with the parameters passed in the URL
//Use the 'getParmVal' function below to get the parameter values from the URL
var filterV = getParmVal('sysparm_filter');
var filterTypeV = getParmVal('sysparm_filtertype');
var vulV = getParmVal('sysparm_vulid');
if(filterV){
g_form.setValue('u_vulnerability_filter',filterV);
}
if(vulV){
g_form.setValue('u_vulnerable_ids',vulV);
}
if(filterTypeV){
g_form.setValue('u_filter_type',filterTypeV);
}
}
function getParmVal(name) {
name = name.replace(/[[]/, "\\[").replace(/[\]]/, "\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(top.location);
if (results == null) {
return "";
} else {
return unescape(results[1]);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2022 07:16 AM
Hello Harshad,
The results return as null. I have alerted as below.
I dont see any url returning here. what I did is correct??
function getParmVal(name) {
name = name.replace(/[[]/, "\\[").replace(/[\]]/, "\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(top.location);
alert('results' + results);
if (results == null) {
return "";
} else {
return unescape(results[1]);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-07-2022 12:09 PM
is this something you can help? Please
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2022 04:22 AM
Hi
Could you please help us here.
Advance thanks.