- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2020 09:56 AM
Hi All!
It is way too long a story to explain why I need this, but I am looking for a function or something that can run and encoded query against a retrieved gliderecord object to see if it meets the criteria of the the encoded query.
Doing this in a widget in service portal.
I hope I am explaining that well if not here is code to try to help explain what I need:
var gr = new GlideRecord("table_name");
gr.get("342sysid54325");
var boolean = gr.EncodedQueryFunctionThatINeed("active=true^short_description=hellothere^name=yo"); // <---- THE FUNCTION I NEED
if (boolean) {
console.log("The Record is Active, has a short description of hellothere and is named yo");
} else {
console.log("The Record is either not Active, does not have a short description of hellothere or is not named yo");
}
Solved! Go to Solution.
- Labels:
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2020 08:34 AM
Found out a solution a while back. Just create a new GlideRecord object with the encoded query and the sys_id of the current record you want to check, query the table using the new glide record, and see if it gets an entry back. If it does, it is your record and it matches the query you wanted to check it against.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2020 10:09 AM
Can you try below.
var gr = new GlideRecord("table_name");
gr.addQuery('sys_id','342sysid54325');
//gr.get("342sysid54325");
gr.query();
if(gr.next())
{
var booleanis=gr.getEncodedQuery();
//var boolean = gr.EncodedQueryFunctionThatINeed("active=true^short_description=hellothere^name=yo"); // <---- THE FUNCTION I NEED
if (boolean.includes('active=true^short_description=hellothere^name=yo'))
{
console.log("The Record is Active, has a short description of hellothere and is named yo");
}
else
{
console.log("The Record is either not Active, does not have a short description of hellothere or is not named yo");
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2020 10:40 AM
Hey Jaspal,
That doesn't seem to work. I am not trying to check what the encoded query is. I am more trying to use the encoded query to check the values of certain fields all the same time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2020 11:30 AM
This is possible and the syntax is the following:
GlideFilter.checkRecord(GLIDERECORD, ENCODED-QUERY)
This will result in a true or false answer.
So your code example would be:
var gr = new GlideRecord("table_name");
gr.get("342sysid54325");
if (GlideFilter.checkRecord(gr, "active=true^short_description=hellothere^name=yo")) {
console.log("The Record is Active, has a short description of hellothere and is named yo");
} else {
console.log("The Record is either not Active, does not have a short description of hellothere or is not named yo");
}
Please mark this post or any as helpful or the correct answer to your question if applicable so others viewing may benefit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2020 08:34 AM
Found out a solution a while back. Just create a new GlideRecord object with the encoded query and the sys_id of the current record you want to check, query the table using the new glide record, and see if it gets an entry back. If it does, it is your record and it matches the query you wanted to check it against.