Do you know how many ways we can use ServiceNow Tags.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2025 05:41 AM
All about ServiceNow #Tags,
What are Tags?
-Tags are keywords or phrases that can be assigned to records in ServiceNow to categorize, filter, and search data.
How tags useful?
- Tags enable efficient data management, improve search results, and enhance reporting capabilities.
How do Tags Work?
- Tag Creation: Tags can be created manually or automatically through business rules, workflows, or data imports.
- Tag Assignment: Tags can be assigned to records in various tables, including incidents, problems, changes, and configuration items.
- Tag Hierarchy: Tags can be organized in a hierarchical structure, allowing for nested tags and sub-tags.
Technical Details
- Tag Table: Tags are stored in the `Label` table, which contains fields for tag name, Owner, Viewable, Active & Type etc
- Tag Assignment Table: Tag assignments are stored in the `label_entry` table, which contains fields for tag ID like, title, table, table key, .
- API Support: ServiceNow provides API support for tag creation, assignment, and querying, enabling automation and integration with external systems.
----------------------------------------------------------------------------------------------------------------------------
Example with Code:
- Create a tag 'Hardware' and assign it to all incidents with a category of 'Hardware'
-// Create tag
var tag = new GlideRecord(label');
tag.name = 'Hardware';
tag.description = 'Hardware-related incidents';
tag.insert();
---------------------------------------------
// Assign tag to incidents
var incidentGr = new GlideRecord('incident');
incidentGr.addQuery('category', 'Hardware');
incidentGr.query();
while (incidentGr.next()) {
var tagAssignmentGr = new GlideRecord(‘label_entry');
tagAssignmentGr.initialize();
tagAssignmentGr.label = tag.sys_id;
tagAssignmentGr. 'table_key = incidentGr.sys_id;
tagAssignmentGr.table = 'incident';
tagAssignmentGr.insert();
----------------------------------------------------------------------------------------------------------------------------------------
Use case1:
Created relationship between Project table and kb_knowledge table to fetch Project related articles . Need to tag project(s) to every article while creation.
var query1 = "nameSTARTSWITH" + parent.name;
var defntag = new GlideRecord("label");
defntag.addEncodedQuery(query1);
defntag.query();
if (defntag.next()) {
var query2 = "sys_tags." + defntag.getUniqueValue() + "=" + defntag.getUniqueValue() + "^workflow_state=published";
current.addEncodedQuery(query2);
}
Use case2:
We have custom table holds the list of resolution codes for our different scenarios and businesses (like categories on INC form)
We need to fetch the resolution codes for a scenario, which are different to regular scenarios.
Create set of resolution codes for software category in the resolution code table, so we need to restrict the codes amongst all the category types. Like software codes should not be visible to the other category incs and vise versa. We had to apply the logic in refence qualifier like below,
var grTagEntry = new GlideRecord('label_entry');
grTagEntry.initialize();
grTagEntry.setValue('label', tagSysId); // tagSysId is the sysid of the software tag in label table
grTagEntry.setValue('table', current.getTableName());
grTagEntry.setValue('table_key', current.getUniqueValue());
grTagEntry.insert();
Guidelines for Tag,
These are some recommendations for using text within the record tags component.
- Keep all text labels short and informative to increase
- Keep content concise and purposeful to provide value to the user
- Capitalize only the first letter and any proper nouns in a string of
- Ensure content is contextual and specific to offer guidance and
- Use sentence case for all titles, labels, and column headers
- 352 Views