What’s the difference between GlideRecord’s addQuery() vs. encoded queries – when to use which?

dalvipranit
Giga Explorer

What’s the difference between GlideRecord’s addQuery() vs. encoded queries – when to use which?

9 REPLIES 9

Rafael Batistot
Kilo Patron

Hi @dalvipranit 

 

Here the best explanation 

 

using addQuery() you can give filter based upon the one field,

 

using addEncodedQuery() you can filter the record based upon the multiple fileds (you can copy the breadcrumb string and use as it is in encoded query under quotes).


https://www.servicenow.com/community/service-management-forum/what-is-the-difference-between-add-que...

 

If you found this response helpful, please mark it as Helpful. If it fully answered your question, consider marking it as Correct. Doing so helps other users find accurate and useful information more easily.

svirkar420
Tera Guru

Hi @dalvipranit , The difference between addQuery() and addEncodedQuery() is in case you want to add some simple query like ('state', 'new') the addQuery() would suit best here. But in case where you will need to add more complex and complex filters/queries like more than 2 or 3 conditions at the same time at that time the addEncodedQuery() will be the best as it will directly add the condition you want in a single line instead of adding multiple queries in different line.

So, which should you use, as I told in case you want more complex logic and conditions use encodedQuery() and in case your condition is not complex use addQuery(). 

Hope this helps you!

 

If this solution helped you Please Mark this solution as accepted and helpful as it will be helpful for other users as well.
Best Regards.
Saurabh V.

Hi @dalvipranit , Hope you are doing well, Did my answer helped you in any way??

If my answers given earlier were helpful then Please Mark this solution as accepted and helpful as it will be helpful for other users as well.
Best Regards.
Saurabh V.

Hi @dalvipranit , Did my answer helped you in any way?? 

IF yes then make sure to accept it as a solution and mark it as helpful as this will benefit other users and readers as well.

 

Best Regards,

Saurabh V.