- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2016 07:03 PM
Hi,
I am using following code to run a EncodedQuery
var incquery = new GlideRecord('incident');
incquery.addEncodedQuery('active%3Dtrue^state<6^NQactive%3Dtrue');
incquery.query();
if (incquery.next())
{
}
and i do get the following error.
ava.lang.NullPointerException: java.lang.NullPointerException: com.glide.db.conditions.MultipleCondition.processQuery(MultipleCondition.java:98) com.glide.db.conditions.MultipleCondition.toSQLBuffer(MultipleCondition.java:80) com.glide.db.conditions.QueryCondition.toSQLBuffer(QueryCondition.java:401) com.glide.db.DBQuery.whereClause0(DBQuery.java:1340) com.glide.db.DBQuery.toSQL(DBQuery.java:728) com.glide.db.DBQuery.getSelectStmt(DBQuery.java:629) com.glide.db.DBQuery.executeAsResultSet0(DBQuery.java:243) com.glide.db.DBQuery.executeAndReturnTable(DBQuery.java:229) com.glide.db.DBAction.executeNormal(DBAction.java:204) com.glide.db.DBAction.executeAndReturnException(DBAction.java:167) com.glide.db.RDBMSQueryContext.executeQuery(RDBMSQueryContext.java:46) com.glide.db.DBQuery.execute(DBQuery.java:1735) com.glide.db.meta.Table.queryBasic(Table.java:292) com.glide.db.meta.Table.query(Table.java:189) com.glide.script.GlideRecordITable.query(GlideRecordITable.java:76) com.glide.script.GlideRecord.query0(GlideRecord.java:2828) com.glide.script.GlideRecord.query(GlideRecord.java:2598) com.glide.script.GlideRecord.jsFunction_query(GlideRecord.java:2484) inv7.invoke() org.mozilla.javascript.FunctionObject.doInvoke(FunctionObject.java:565) org.mozilla.javascript.FunctionObject.call(FunctionObject.java:480) org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1201) org.mozilla.javascript.gen.c2418.call(<refname>:4) org.mozilla.javascript.gen.c2418.exec(<refname>) com.glide.script.ScriptEvaluator.execute(ScriptEvaluator.java:162) com.glide.script.ScriptEvaluator.execute(ScriptEvaluator.java:176) com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:68) com.glide.script.Evaluator.evaluateString(Evaluator.java:161) com.glide.script.Evaluator.evaluateString(Evaluator.java:156) com.glide.processors.ScriptProcessor.evaluateScript(ScriptProcessor.java:282) com.glide.processors.ScriptProcessor.runScript(ScriptProcessor.java:201) com.glide.processors.ScriptProcessor.process(ScriptProcessor.java:159) com.glide.processors.Processor.runProcessor(Processor.java:358) com.glide.processors.Processor.processTransaction(Processor.java:163) com.glide.processors.ProcessorRegistry.process(ProcessorRegistry.java:146) com.glide.ui.GlideServletTransaction.process(GlideServletTransaction.java:36) com.glide.ui.GlideServlet$1.run(GlideServlet.java:408) java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918) java.lang.Thread.run(Thread.java:682)
Any pointers?
-Aman
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2016 08:00 PM
Hi Aman,
Your encoded query appears to be partially escaped and is probably being ignored, though I'm not certain why the NullPointerException and not just a full incident query. You could replace those occurrences of %3D with =
Or alternatively unescape the encoded query string
incquery.addEncodedQuery('active=true^state<6^NQactive=true');
or
incquery.addEncodedQuery(unescape('active%3Dtrue^state<6^NQactive%3Dtrue'));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2016 08:00 PM
Hi Aman,
Your encoded query appears to be partially escaped and is probably being ignored, though I'm not certain why the NullPointerException and not just a full incident query. You could replace those occurrences of %3D with =
Or alternatively unescape the encoded query string
incquery.addEncodedQuery('active=true^state<6^NQactive=true');
or
incquery.addEncodedQuery(unescape('active%3Dtrue^state<6^NQactive%3Dtrue'));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2016 08:21 PM
Hi Anthony,
Thanks for the reply. I tried that before adding the post and that is the only way to solve the issue.
-Aman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2016 10:04 PM
Hi Aman,
If you want to use an encoded query it is a good idea to build the query in a list view and copy it.
For example:
active=true^state<6^ORactive!=true
This means the the syntax is always correct plus you can check the logic is in line with what you want to achieve by looking at the result set.
Best Regards
Tony