add tags to a record on insert

randrews
Tera Guru

Ever want to add a tag to EVERY record created on a table?? you CAN!!

My business case for this is our enhancement requests... we have a "Whats new" meeting prior to each release and go over everything we want to show off <mostly everything>

To facilitate the call i go through each enhancement in that release that has the correct tag... but i   am tired of adding that tag.. when 95% of our new enhancements NEED the tag... i would rather remove it as add it... sooo the following script will add a tag to a record..... i plan on running this in an on insert br.. please let me know if you see any issues with this concept!

var tablename = 'Enhancement';

var tag_sysid = '60515d501334f2409f507e776144b07c';

var le = new GlideRecord('label_entry');

le.initalize();

le.id_display = current.number;

le.id_type = tablename;

le.label = tag_sysid;

le.notify_onchange = false;

le.read = 'yes';

le.table = current.sys_class_name;

le.table_key = current.sys_id;

le.title = tablename + ' - ' + current.number;

le.url = current.sys_class_name + '?sys_id=' + rec.sys_id + '&sysparm_view=';

le.insert();

3 REPLIES 3

sachin_namjoshi
Kilo Patron

Hi Raymond,



Please don't hardcode sys_id in your business rule.


Instead you can create system property and refer system property value in your code.



In your case , i will suggest to create report of enhancement to be reviewed and pull this report on dashboard. ( may be PA dashboard).


You can look into change calendar functionality where CAB members reviews changes every week before approving them.



Regards,


Sachin


good idea to put it in a property makes it more flexible..



as far as the dashboard.. naaa this is a Group meeting that i go over all of our release stuff with 100+ users .. the whole purpose of the tags is to sort the enhancements in the release into those i DO want to cover... and those i do NOT want to cover...



tags are perfect for meetings like this.


Sanjeev Kumar1
Kilo Sage

Hi,

 

you can use.

 

Configure tags to assign automatically 

https://docs.servicenow.com/bundle/london-platform-user-interface/page/use/common-ui-elements/concep...