URL is too large

ar1
Kilo Sage

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:

ar1_0-1673174117416.png

 

18 REPLIES 18

Hi Ajay,
Many thanks for the response.
One the thread we saw to check the calculated checkbox as true and mention some javascript code
we tried the logic but it's not working and the url also not showing on field level.

Advance thanks.

Can you share your script here?

Hi Ajay,
Thanks for the response.
Please find the below BR script:

(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);

 

Advance thanks.

If you are using calculated as true then you need to write this script in the calculated script and not in the business rule. But anyways this will behave the same as a URL field as you have created earlier. This is the reason I was suggesting to check for creating a hyperlink which is possible if you create a field as HTML type. And you can hide the toolbars with the below option:

https://www.servicenow.com/community/developer-forum/is-there-a-way-to-hide-the-html-field-editor-to... 

 

Another solution which you can try is creating a string field as mentioned in below thread:

https://www.servicenow.com/community/itsm-forum/need-help-in-adding-a-link-in-string-type-field/m-p/...