What is the replacement of GlideURI API ?

Anmol6
Mega Contributor

Hi, 

What is the replacement of GlideURI API, since it's is generating warning logs - Null Pointer exception error can't convert null to an object so do we have replacement of it so that we can avoid those logs. I have used it in my BR.

 

 

 

 

Thanks,

Anmol

 

1 ACCEPTED SOLUTION

Hello Anmol,

 

This is the expected behaviour and ServiceNow suggests that it should not be executed during export or any background job.

Please check the article I've posted in the above thread.

 

Hope this helps. 

 

Regards

Omkar Mone

View solution in original post

9 REPLIES 9

Gaurav Shirsat
Mega Sage

Hi Anmol

  • public class GlideUrl
    extends java.lang.Object
    implements Key
    A wrapper for strings representing http/https URLs responsible for ensuring URLs are properly escaped and avoiding unnecessary URL instantiations for loaders that require only string urls rather than URL objects.

    Users wishing to replace the class for handling URLs must register a factory using GlideUrl.

    To obtain a properly escaped URL, call toURL(). To obtain a properly escaped string URL, call toStringUrl(). To obtain a less safe, but less expensive to calculate cache key, call getCacheKey().

    This class can also optionally wrap Headers for convenience.

    https://bumptech.github.io/glide/javadocs/490/com/bumptech/glide/load/model/GlideUrl.html

     

     

    Please Mark Correct and Helpful

    Thanks and Regards

    Gaurav Shirsat

Hi Gaurav,

Thanks for sharing this but I'm unable to achieve the functionality through the BR, I call toUrl, toStringUrl but unable to get the URL.

 

 

Thanks,

Anmol

Omkar Mone
Mega Sage

Hello Anmol,

 

Could share your code snippet with us so that we can help you triage/solve the issue, Is it a Query BR?

Please check the below article as well -

https://hi.service-now.com/kb_view.do?sysparm_article=KB0623094

 

Regards

Omkar Mone 

Hi Omkar,

Yes it is before Query BR on cmdb_ci table. code for the BR is as follows -

(function executeRule(current, previous /*null when async*/) {


var referer = GlideTransaction.get().getRequest().getHeader("referer");
//gs.addInfoMessage("answer " + ref);
if(typeof referer != "undefined" && referer.indexOf('http'));
var uri = gs.action.getGlideURI().toString();

if(typeof uri != "undefined" && (uri.indexOf('change_request.cmdb_ci') > -1))
current.addQuery('sys_class_name','cmdb_ci_service');
//if(current == null)
//return;
//gs.addInfoMessage("answer " + current);

})(current, previous);

 

Thanks,

Anmol