- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2018 11:36 PM
Hi Friends,
I am trying to customize OOB BR "user_query" on sys_user table to allow listing of all users(active+inactive) when URL consists of certain texts. I configured BR like this:
if(gs.action)
var uri = gs.action.getGlideURI().toString();
if(typeof uri != "undefined" && ((uri.indexOf('getReqFor') > -1) || (uri.indexOf('sc_cart.requested_for') > -1) || (uri.indexOf('catalog_default') > -1) || (uri.indexOf('com.glideapp.servicecatalog_cat_item') > -1)))
current.getUniqueValue(); //This is just a placeholder for IF, not using this code's output anywhere.
else
current.addActiveQuery();
However I recieve occassional java.lang.NullPointerException.
During troubleshooting I tried following:
1. Put a check for validating if "gs.action" contains some value.
2. Put a check for validating if "gs.action.getGlideURI()" contains some value.
3. Noticed that the error always comes when "AMB_RECEIVE-thread" is calling the script.
2018-11-23 08:09:43 (363) AMB_RECEIVE-thread-39 FF74080035C66B0003158E4BCB442BB4 Couldn't decipher the stack trace resulting from the following JavaScriptException:
2018-11-23 08:09:43 (364) AMB_RECEIVE-thread-39 FF74080035C66B0003158E4BCB442BB4 SEVERE *** ERROR *** java.lang.NullPointerException
org.mozilla.javascript.JavaScriptException: java.lang.NullPointerException
at org.mozilla.javascript.Context.makeJavaScriptException(Context.java:1925)
at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1911)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:143)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:292)
at org.mozilla.javascript.ScriptRuntime.doCall(ScriptRuntime.java:2585)
at org.mozilla.javascript.optimizer.OptRuntime.callProp0(OptRuntime.java:85)
at org.mozilla.javascript.gen.sys_script_62a7bfaf0a0a0a6500c49682bd82376a_script_10165._c_script_0(sys_script.62a7bfaf0a0a0a6500c49682bd82376a.script:1)
at org.mozilla.javascript.gen.sys_script_62a7bfaf0a0a0a6500c49682bd82376a_script_10165.call(sys_script.62a7bfaf0a0a0a6500c49682bd82376a.script)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:563)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3421)
at org.mozilla.javascript.gen.sys_script_62a7bfaf0a0a0a6500c49682bd82376a_script_10165.call(sys_script.62a7bfaf0a0a0a6500c49682bd82376a.script)
at org.mozilla.javascript.gen.sys_script_62a7bfaf0a0a0a6500c49682bd82376a_script_10165.exec(sys_script.62a7bfaf0a0a0a6500c49682bd82376a.script)
at com.glide.script.ScriptEvaluator.execute(ScriptEvaluator.java:263)
at com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:110)
at com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:76)
at com.glide.script.fencing.GlideScopedEvaluator.evaluateScript(GlideScopedEvaluator.java:343)
at com.glide.script.fencing.GlideScopedEvaluator.evaluateScript(GlideScopedEvaluator.java:263)
at com.glide.script.fencing.GlideScopedEvaluator.evaluateScript(GlideScopedEvaluator.java:250)
at com.glide.script.BusinessRule.runScript(BusinessRule.java:403)
at com.glide.script.BusinessRule.runSyncBusinessRule(BusinessRule.java:293)
at com.glide.script.BusinessRule.runBusinessRule(BusinessRule.java:204)
at com.glide.script.BusinessRule.run(BusinessRule.java:180)
at com.glide.script.GlideRecordBusinessRules.run(GlideRecordBusinessRules.java:87)
at com.glide.script.GlideRecord.runScripts(GlideRecord.java:1298)
at com.glide.script.GlideRecord.addBeforeQueryRules(GlideRecord.java:3288)
at com.glide.script.GlideRecord.prepQuery(GlideRecord.java:3275)
at com.glide.script.GlideRecord.query0(GlideRecord.java:3165)
at com.glide.script.GlideRecord.get(GlideRecord.java:1641)
at com.glide.amb.server.AMBGlideRecordSerializer.deserializeRecord(AMBGlideRecordSerializer.java:60)
at com.glide.amb.server.AMBGlideRecordReceiveValidator.send(AMBGlideRecordReceiveValidator.java:39)
at org.cometd.server.ServerSessionImpl.notifySend(ServerSessionImpl.java:763)
at org.cometd.server.ServerSessionImpl.extendSendMessage(ServerSessionImpl.java:751)
at org.cometd.server.ServerSessionImpl.doDeliver(ServerSessionImpl.java:254)
at com.glide.amb.server.GlideCometdServerSessionImpl.handleDeferral(GlideCometdServerSessionImpl.java:41)
at com.glide.amb.server.AbstractAMBContext.handleDeferral(AbstractAMBContext.java:233)
at com.glide.amb.server.GlideAMBProcessor.process(GlideAMBProcessor.java:16)
at com.glide.processors.AProcessor.runProcessor(AProcessor.java:474)
at com.glide.processors.AProcessor.processTransaction(AProcessor.java:199)
at com.glide.processors.ProcessorRegistry.process0(ProcessorRegistry.java:178)
at com.glide.processors.ProcessorRegistry.process(ProcessorRegistry.java:167)
at com.glide.ui.GlideServletTransaction.process(GlideServletTransaction.java:31)
at com.glide.sys.Transaction.run(Transaction.java:2037)
at com.glide.amb.server.AMBTransaction.run(AMBTransaction.java:25)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
2018-11-23 08:09:43 (366) AMB_RECEIVE-thread-39 FF74080035C66B0003158E4BCB442BB4 SEVERE *** ERROR *** JavaScript evaluation error on:
if(gs.action.getGlideURI())
var uri = gs.action.getGlideURI().toString();
if(typeof uri != "undefined" && (uri.indexOf('getReqForAndCostCenter') > -1 || uri.indexOf('sc_cart.requested_for') > -1 || uri.indexOf('catalog_default') > -1 || uri.indexOf('com.glideapp.servicecatalog_cat_item') > -1))
current.getUniqueValue(); //DO NOTHING
else
current.addActiveQuery();
Root cause of JavaScriptException: java.lang.NullPointerException
java.lang.NullPointerException
However unable to tracedown which line or piece of code in BR could be causing this error.
PS> I do not get error when I manaully run the code. It only happens when AMB_RECEIVE-thread is involved.
Could someone help me troubleshoot this?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-25-2018 10:48 PM
Adding this check before the 'if' block fixed the issue:
/* FIX - Start */
var ref = GlideTransaction.get().getRequest().getHeader("referer");
if(ref && ref.indexOf('http'));
var uri = gs.action.getGlideURI().toString();
/* FIX - End */
if(typeof uri != "undefined" && ((uri.indexOf('getReqFor') > -1) || (uri.indexOf('sc_cart.requested_for') > -1) || (uri.indexOf('catalog_default') > -1) || (uri.indexOf('com.glideapp.servicecatalog_cat_item') > -1)))
current.getUniqueValue(); //This is just a placeholder for IF, not using this code's output anywhere.
else
current.addActiveQuery();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2018 11:58 PM
Got this document explaining the cause :
Now I need to know another way to get URL in Business Rule, could someone help?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2018 12:01 AM
Try adding these conditions and see if that helps.
gs.action != ''
gs.getSession().isInteractive()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-23-2018 04:55 AM
Thanks for your reply.
OOB BR user_query has gs.getSession().isInteractive() set in condition field so it should not execute if the value is false anyway.
and validating gs.action I already checked, it did not work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-25-2018 10:48 PM
Adding this check before the 'if' block fixed the issue:
/* FIX - Start */
var ref = GlideTransaction.get().getRequest().getHeader("referer");
if(ref && ref.indexOf('http'));
var uri = gs.action.getGlideURI().toString();
/* FIX - End */
if(typeof uri != "undefined" && ((uri.indexOf('getReqFor') > -1) || (uri.indexOf('sc_cart.requested_for') > -1) || (uri.indexOf('catalog_default') > -1) || (uri.indexOf('com.glideapp.servicecatalog_cat_item') > -1)))
current.getUniqueValue(); //This is just a placeholder for IF, not using this code's output anywhere.
else
current.addActiveQuery();