Not able to use "addEncodedQuery()" function on client script

sr_surendra
Giga Expert

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.

find_real_file.png

Can someone please help me on it

 

Regards,

Surendra

10 REPLIES 10

sr_surendra
Giga Expert

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.

 

find_real_file.png

 

find_real_file.png

Hi,

 

Please check this out. 

 

https://docs.servicenow.com/bundle/jakarta-platform-user-interface/page/use/using-lists/concept/c_En...

 


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

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.

masoomsharma
Tera Contributor

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.

sr_surendra
Giga Expert

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