URL is too large
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2023 02:38 AM
Hi All,
Can anyone please help us on the below issue.
We created one business rule to set one table records url in one URL type field called "Data Link" and when an user click on the url it will open new records list view in new tab.
But sometimes when we get more than 50 records url, after click on the url we're getting below error.
Please help us to complete this.
Advance thanks.
Error Image:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 12:47 AM - edited 01-09-2023 12:47 AM
This is because of restriction of URL length which I think is not controlled in servicenow instance, try below and check if this works:
(function executeRule(current, previous /*null when async*/ ) {
setLink();
function setLink() {
gs.info("inside function");
var d = [];
var d1 = [];
var di=new GlideRecord('sec_cmn_src_ci');
di.addEncodedQuery('cmdb_ci.sys_class_name=cmdb_ci_firewall_device_cisco^last_scan_dateONLast 90 days@javascript:gs.beginningOfLast90Days()@javascript:gs.endOfLast90Days()^cmdb_ci.operational_status=1');
di.query();
while (di.next())
{
gs.info("inside first loop");
d.push(di.cmdb_ci.toString());
}
var ci = new GlideRecord("cmdb_ci");
ci.addEncodedQuery('sys_class_name=cmdb_ci_firewall_device_cisco^operational_status=1');
ci.addQuery('sys_id', 'NOT IN', d);
ci.query();
while (ci.next()) {
gs.info('inside second loop');
d1.push(ci.getValue("name"));
}
gs.info("d1 is" + d1);
for (var i = 0; i < d1.length; i++)
{
var url = gs.getProperty('glide.servlet.uri') + '/nav_to.do?uri=' + 'cmdb_ci' + '_list.do?sysparm_query=nameIN' + d1;
gs.info("link is" + url);
current.u_data_link = url;
}
}
})(current, previous);
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 12:54 AM - edited 01-09-2023 01:25 AM
Hi Raghav,
Many thanks for the response.
We tried your above suggestion, then it's not displaying any records when we clicks on the URL.
Earlier when we send the "sys_id"s we're able to see the records.
NOTE: Is there any way to call the same script logic using Ui Pages.
OR
is there any possibility to call the stored url "custom field" in UI pages or Ui actions.
Advance thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 02:18 AM
can you try below:
(function executeRule(current, previous /*null when async*/ ) {
setLink();
function setLink() {
gs.info("inside function");
var d = [];
var d1 = [];
var di=new GlideRecord('sec_cmn_src_ci');
di.addEncodedQuery('cmdb_ci.sys_class_name=cmdb_ci_firewall_device_cisco^last_scan_dateONLast 90 days@javascript:gs.beginningOfLast90Days()@javascript:gs.endOfLast90Days()^cmdb_ci.operational_status=1');
di.query();
while (di.next())
{
gs.info("inside first loop");
d.push(di.cmdb_ci.toString());
}
var ci = new GlideRecord("cmdb_ci");
ci.addEncodedQuery('sys_class_name=cmdb_ci_firewall_device_cisco^operational_status=1');
ci.addQuery('sys_id', 'NOT IN', d);
ci.query();
while (ci.next()) {
gs.info('inside second loop');
d1.push(ci.getValue("name"));
}
gs.info("d1 is" + d1);
for (var i = 0; i < d1.length; i++)
{
var url = gs.getProperty('glide.servlet.uri') + '/nav_to.do?uri=' + 'cmdb_ci' + '_list.do?sysparm_query=nameLIKE' + d1;
gs.info("link is" + url);
current.u_data_link = url;
}
}
})(current, previous);
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 02:24 AM
HI Raghav,
Thanks for the response.
We tried your suggestions, but no luck.
After change from sys_id to name both the places, we're not getting any records when we clicks on the URL.
Advance thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2023 01:56 AM
Hello,
One of the solution can be to use hyperlinks instead of showing the full URL to the users.
Below is something about hyperlinks:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0759336
- Ajay