Making tags mandatory?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2016 01:37 PM
Hi,
is there a way to make Tags mandatory?
would like to force user to select at least 1 tag before closure
/Daniel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2016 02:02 PM
You can but it is tricky since tags (aka labels) are stored in a separate table and linked to tasks. Tags used to be called Labels and the Tag names themselves are stored in a table called "label". Then there is a record called Label Entry that links a tag to a record. So you could create a business rule that runs when the state is closed to query this label_entry table to see if there is a record and if not prevent save.
Example Business Rule that worked in a quick test when changing state to In Progress:
Then on the advanced tab use the following script:
(function executeRule(current, previous /*null when async*/) {
var labelEntry = new GlideRecord("label_entry");
labelEntry.addQuery("table", current.sys_class_name);
labelEntry.addQuery("table_key", current.sys_id);
labelEntry.query();
if (!labelEntry.hasNext()) {
current.setAbortAction(true);
gs.addErrorMessage("You must select at least one Tag.");
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2016 12:47 PM
Great, that's a straight forward solution.
i was also trying to find out if it would be possible to reuse the macro from editing tag in list view... as has more functionality.
