- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2020 12:25 AM
Hi,
I have to glide Application table and use those records which are marked as critical in tag field, but I am not able to fetch value tag field value. Please help how I can query this field and glide the records.
thanks,
Gazal Varshney
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2020 12:57 AM
Hi,
tags are stored in this table
Tags [label];
label entries are stored in this table Label Entry [label_entry]
Example: Consider I have marked tag as "Hello" to one incident on incident table; so below script would tell which incident number has that tag
var incArray = [];
var tag = new GlideRecord('label_entry');
tag.addQuery('label.name','Hello');
tag.addQuery('table','incident');
tag.query();
while(tag.next()){
incArray.push(tag.getValue('id_display'));
}
gs.info('Array is: ' + incArray);
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2020 12:42 AM
the screenshot which you have shared, it has not any tag value.
tag record stored in table "label_entry" and there is column label , which store the tag value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2020 12:57 AM
Hi,
tags are stored in this table
Tags [label];
label entries are stored in this table Label Entry [label_entry]
Example: Consider I have marked tag as "Hello" to one incident on incident table; so below script would tell which incident number has that tag
var incArray = [];
var tag = new GlideRecord('label_entry');
tag.addQuery('label.name','Hello');
tag.addQuery('table','incident');
tag.query();
while(tag.next()){
incArray.push(tag.getValue('id_display'));
}
gs.info('Array is: ' + incArray);
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2020 01:08 AM
sample code to fetch the tag value.
var gr= new GlideRecord('label_entry');
gr.addQuery('id_display','INC0010367');// here you will add ticket number
gr.addQuery('table','incident');
gr.query();
while(gr.next()){
gs.print ('Tag is: ' + gr.label.getDisplayValue());
}