Issue with UI action condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2024 07:42 AM
I am working on a UI action to "Copy Security Incident". But it should show only when there is a special security tag (lets call it 'XYZ').
I am giving condition -
current.security_tags.indexOf('sys id of XYZ') != -1.
Issue I am facing - The UI action is visible on the SIR's where there is no security tag as well.
Please help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2024 08:25 AM
Tags work differently than you would expect. Your condition needs to call to a Script Include and function like:
new global.sirUtils().getTags(current);
using 'global' if you create the Script Include in this scope. The getTags function would query the label_entry table to see if the current SIR has a record for that tag, so like this:
getTags: function(current) {
var labelEntry = new GlideRecord('label_entry');
labelEntry.addQuery('table', 'incident'); //replace with security incident table
labelEntry.addQuery('label', 'bf16bf4493e85690c7d735018bba10b6'); //sys_id of tag
labelEntry.addQuery('table_key', current.sys_id);
labelEntry.query();
if (labelEntry.next()) {
return true;
}
return false;
},
With this Condition, the SI returning true will show the UI Action, returning false will hide it.