Add tags to incident from Rest Api
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2016 02:11 AM
Is there any way of adding a tag to an incident using the rest api? i have tried using the incident, label and label_entry table, and i can not seem to get it to work.
I've tried the sys_tags field in the incident table to no success.
same goes for trying to fill out the table and table key in label_entry table
- Labels:
-
Service Mapping
- 4,909 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2016 10:56 AM
Here is an example using jquery.
$.getJSON("/data_table.do",{sysparm_type: "labels", sysparm_table: "incident",
sysparm_sys_id: "INCIDENT SYS ID", sysparm_label: "YOUR-TAG",
sysparm_action: 'add'})
.done(function(data) {
//returns JSON data.sysId, data.name and other parameters;
})
.fail(function(jqXHR, textStatus, errorThrown){
alert('Could not add tag:' + textStatus + errorThrown);
});
you can also use 'removeById' and 'existing_labels' to remove and get new labels, or if you are integrating..
/data_table.do?sysparm_type=labels&sysparm_table=incident&sysparm_sys_id=incident.sys_id&sysparm_label=LABEL_NAME&sysparm_action=add
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-04-2017 07:18 AM
Hi,
Did you get an answer as to what tables should be updated via API to add a tag?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2020 01:45 AM
1. When you want to add a tag to a incident,change or any task records, You have to create an entry into the label_entry table.
2. Create a label - test in the label table and copy the sys_id of the label test.
3. Now navigate to REST API page.
https://<instance-name>.service-now.com/nav_to.do?uri=%2F$restapi.do
4. Choose the table API and use the option - create a record.
5. select the table name - label_entry.
6.Request body - refer to the screenshot attached.
Table - incident.
Table key - sys_id of the incident record that has to be updated with the tag.
Label - sys_id of the tag(test) from the Label table.
title - <string of your choice>
Click on SEND and the 201 Created.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2020 12:33 AM
As a one time call ,its working fine the response is coming as 201 Created. But when i go into the system and see the label entry associations for the tag , the entry is created but the table and table_key are not populated , i got to find out that there are field level acl's which are expecting maint role for writing on these fields.
Even the tag is not associated to the record in the system.
And next time when i perform the same call with the change in the table key it sayd 403 Forbidden and then says a business rule "Prevent Duplicate Label Entries" is aborting the insertion
as it checks for duplicate label entries based on the fields.
as the previous insertion was having label as same "tag name" and table and table_key are again inserted as being blank , its behaving as a duplicate record insertion .
Is it that we need to remove the maint role enforced in order to make this work ?
Regards,
Siva