Not able to use "addEncodedQuery()" function on client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2018 09:51 AM
Dear all,
I've written on submit script on catalog task table.
this script contain addEncodedQuery function.
this script is giving error while submitting as shown in screenshot below while closing catalog task.
Can someone please help me on it
Regards,
Surendra
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2018 10:06 AM
Hello Allan,
Purpose of this script is , not to allow to submit task if affected ci which is related list of catalog task, is not selected.
This should be applicable for few catalog items and one of assignment group only which I'm mentioning in this encoded string.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2018 10:13 AM
Hi,
Please check this out.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2018 10:28 AM
Can you try gr.encodedQuery = 'Your Query String'; instead of gr.addEncodedQuery('Your Query String');
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2018 10:38 AM
Hi Surendra,
Please avoid using GlideRecord within client script as it is not recommended. I would suggest to call Script Include using synchronous GlideAjax call.
I guess you are doing some mistake in the syntax of using EncodedQuery . Please build your query like below :
var queryString = "priority=1^ORpriority=2"; var gr = new GlideRecord('incident'); gr.addEncodedQuery(queryString); gr.query(); while (gr.next()) { gs.addInfoMessage(gr.number); }
OR
var gr = new GlideRecord('incident'); gr.addEncodedQuery('priority=1^ORpriority=2');
gr.query();
while (gr.next())
{
gs.addInfoMessage(gr.number);
}
Also Please try to use different variable than gr.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2018 11:24 AM
Dear all,
I guess addEncodedQuery() function not works on client script.
So instead useing it on client script I used it on script include and its working.
Thanks to all of you !!
Surendra