- 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
09-24-2020 08:19 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2020 04:59 PM
Sure! This is a simplish coded example of what i did
//This is the sys id of the record I want to check
var sysID = '1234567';
//Glide record for the table that the record resides on
var gr = new GlideRecord("table_name");
//Add the sys id to the encoded query that I wanted to check against the record
gr.addEncodedQuery("sys_id="+ sysID +"active=true^short_description=hellothere^name=yo");
//Query the table
gr.query();
/*If the glide record finds a record then it is the record that has the SYS ID and matches the encoded query. Thus the record matches the encoded query*/
if (gr.next()) {
console.log("The record with sys id 1234567 matches the encoded query of active=true^short_description=hellothere^name=yo");
}
Hope that helps!