I am trying to add a tag to a service now incident, but I can't find any documentation for it anywhere. I have looked at the label and label_entry tables in the incident api. And I can not seem to tie an incident and a label together.
-
Have you tried setting the "sys_tags" field in your REST insert? I think it should work, but I haven't actually tested it – Joey Aug 22 '16 at 16:52
-
I just tested it and it DOESN'T work... I'm inclined to think it's actually a defect, and you may want to file it with ServiceNow support. I tried PUTing to the REST endpoint "/api/now/table/incident/385006530b1122008db1ce3ff6673a2c" with the payload: "{"sys_tags":"a_tag"}" and it did not work :( I think it ought to work. – Joey Aug 23 '16 at 00:56
-
ye, i've tried every single combination of post, put and get requests with different payloads and i just cant seem to make it work – Jonas Olesen Aug 23 '16 at 06:29
-
Was there ever a resolution to this @JonasOlesen? I am facing the same exact issue – Rob DePietro Apr 12 '21 at 13:53
2 Answers
In theory, it should be possible to do this by creating a record in the label_entry table, providing the sys_id of the tag, table and sys_id of the record you'd like to associate the tag with. After a quick test:
POST /api/now/table/label_entry
{"label":"4f1094ff13162600973e70d66144b033","table":"incident","table_key":"0d97240e13aca600973e70d66144b03f","title":"Incident - INC0010018"}
I found that the table and table_key fields have write ACLs restricting access to users with the maint role. I don't have any info on why this is the case, but I suspect there may be a reason to avoid creating these records directly via API.
You could modify the ACLs or create a simple Scripted REST API that takes the tag, target record, and uses GlideRecord to insert the tag into the label_entry table. But I don't have any info on what side effects this may introduce.

- 303
- 1
- 4
Creation of Tag is possible via api but you can not link api created Tag to incident.
You can create tag by inserting record in "Label" and "Label_entry table" but in "Label_entry" Table column Table and Table Key (this is to link the Incident with Tag) is read only
{"label":"036d0358db091f00fca43e1f7c9619pp","read":"yes","table":"incident","table_key":"24df3a484f8672c09d37a8fe0310c753","title":"Incident - INC0028899","link": "https://tgroupdev.service-now.com/api/now/table/sys_user/036d0358db091f00fca43e1f7c9619pp", "value": "036d0358db091f00fca43e1f7c9619pp"}
You can manage Tag by creating a Tag and then applying conditions to Auto Assign Tag to Incident. Please see the below detail
Create a tag from the Tags list You can create a tag directly from the Tags list.
Before you begin
Role required: tags_admin Procedure
Navigate to System Definition > Tags or Self-Service > My Tags. Click New. Enter a name for the tag in the Name field. (Optional) Modify tag settings. Field Description Owner Specifies the owner of the tag. Users are allowed to change the ownership of the tag to someone else. Type Specifies the type of tag. Standard: is controlled by users who have access to the tag. These users can add or remove records from the tag. Most Active: displays the most frequently accessed modules and is automatically maintained by the system. There is no maximum duration a module can remain as most active. Most Recent: displays the most recently accessed modules and is automatically maintained by the system. Most Active Record: displays the most frequently viewed records and is automatically maintained by the system. There is no maximum duration a record can remain as most active. Most Recent Record: displays the most recently viewed records and is automatically maintained by the system. Only tags of the Standard or Most Recent Record types appear on the Tagged Documents page. You can view other types of tags by adding them to a homepage. For more information, see Add a tag to a homepage.
Viewable by Specifies the sharing level. By default tags are visible only to the user (Me), but you can share tags with Groups and Users. Users with the tags_admin role are the only users who can create global tags shared with Everyone. Active Specifies whether the tag is enabled or disabled. Edit tags from the Tags module From the Tags module, you can edit all tags.
Before you begin
Role required: tags_admin About this task
Note: Tag names are case-insensitive and must not include punctuation. Procedure
Navigate to System Definition > Tags. Open a tag. Make the necessary changes. Click Update. Configure tags to assign automatically You can configure the system to automatically assign a tag to records that match conditions defined in the tag record.
Before you begin
Role required: tags_admin About this task
For example, you can create tags that group high urgency incidents, overdue incidents, canceled changes, or any other set of records. The system automatically assigns the tag to records that match the criteria and removes the tag from records that no longer match the criteria.
Procedure
Navigate to System Definition > Tags. Open the tag that you want to assign automatically. Configure the form to add the Conditions for Tags embedded list. Create a row in the Conditions for Tags list. Click the reference icon in the Table column. The Label Table list opens in a pop-up window. Click New. Enter a Name, select a Table, and add conditions for the automatic assignment of the tag. Click Submit. Click the check mark icon to save the new row. Click Update. Configure notifications for tagged records You can enable the system to send a notification when a record with a certain tag is updated.
Before you begin
Role required: tags_admin Procedure
Navigate to System Definition > Tags. Open a tag. In the Label Entries related list, open the record for which you want notifications. Select the Notify onchange check box to be notified any time the record is modified. Use the Notify when condition builder to specify the conditions that must be true to trigger the notification. Select a business rule in the Notify script field. Save the record. https://docs.servicenow.com/bundle/jakarta-platform-user-interface/page/use/common-ui-elements/concept/administering-tags.html

- 11
- 1