Issue with UI action condition

Jasjit
Tera Contributor

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!

1 REPLY 1

Brad Bowman
Kilo Patron
Kilo Patron

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.