Adding tag to a record

samadam
Kilo Sage

I want to add tag to a record while creating a record from a script. Tried to create a tag in the Tags table and used :

rec.sys_tags = "c4567bbd97086ad0523cb12ad0532345";
 
it did not work. Any other ideas?
1 ACCEPTED SOLUTION

Robbie
Kilo Patron

Hi @samadam,

 

It's not actually possible to add a tag with a simple one liner (I assume without visibility of your whole script), but you can add the tag using similar syntax to the below:

 

 

var tagGR = new GlideRecord('label_entry')
tagGR.initialize();
tagGR.label = 'sys id of tag'; 
tagGR.table ='incidet';
tagGR.table_key = 'sys_id of incident'
tagGR.insert();

 

Please also note, it is possible to assign a tag automatically through match conditions defined in the tag record. Check the SN Docs link for more info:

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

 

To help others (and for me to gain recognition for my efforts), please mark this response correct by clicking on Accept as Solution and/or Kudos.




Thanks, Robbie

View solution in original post

3 REPLIES 3

Robbie
Kilo Patron

Hi @samadam,

 

It's not actually possible to add a tag with a simple one liner (I assume without visibility of your whole script), but you can add the tag using similar syntax to the below:

 

 

var tagGR = new GlideRecord('label_entry')
tagGR.initialize();
tagGR.label = 'sys id of tag'; 
tagGR.table ='incidet';
tagGR.table_key = 'sys_id of incident'
tagGR.insert();

 

Please also note, it is possible to assign a tag automatically through match conditions defined in the tag record. Check the SN Docs link for more info:

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

 

To help others (and for me to gain recognition for my efforts), please mark this response correct by clicking on Accept as Solution and/or Kudos.




Thanks, Robbie

samadam
Kilo Sage

This is what I ended up doing and it worked.

Awesome! Thanks for circling back @samadam and helping others in the community.

Happy Tuesday ; )

 

To help others (and for me to gain recognition for my efforts), please mark this response correct by clicking on Accept as Solution and/or Kudos.




Thanks, Robbie