use business rule to search a record on a table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2022 12:39 PM
How to I use glide record to search for a record in a business rule on the incident table. I'm new to scripting and not sure how to structure the script with proper syntax.
for context: this is my assignment.
You are going to be using GlideRecord in a business rule to search the 'incident' table for a record with the number of 'INC001****'. Once you find a match, take the "short_description" and display it at the top of this form via information message
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2022 12:53 PM
So they are providing you the table name and the number of the record, so you would construct your GlideRecord Query like this: edit - corrected a syntax error, apologies.
(function executeRule(current, previous /*null when async*/ ) {
var shortDescription = '';
var inc = new GlideRecord('incident'); // the table name
inc.addQuery('number', 'INC0000015'); // add a query for the field number and provide the FULL incident number!
inc.query(); //execute the query
if (inc.next()) {
//if we returned a record, set the shortDescription
shortDescription = inc.getValue('short_description');
}
//Then display your message if you found the record
if (shortDescription) {
gs.addInfoMessage(shortDescription);
}
})(current, previous);
I hope this helps!
If this was helpful, or correct, please be kind and mark the answer appropriately.
Michael Jones - Proud member of the GlideFast Consulting Team!
Michael D. Jones
Proud member of the GlideFast Consulting Team!