Adding tags to new incident using API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2019 03:19 AM
Hi,
I have spent several hours on this, read too many posts here and on stackoverflow, but I could still not find the answer.
Adding a tag to an incident from the web UI, is simple and easy, and using the API to filter on them is somewhat more complicated (using sys_tags.d93c20034f2a3....21a310c74e=d93c20034f2a33....e321a310c74e), but doable.
What I can't figure out is, how do I create a new incident with a tag. using "sys_tags" is useless - it always returns empty, and doesn't save any value.
If I add a tag manually using the web interface, and then retrieve all incidents using sysparm_display_value=all, I can see the tags in sys_tage.display_value field, but I cant find a way to set this field using an API call.
Thanks,
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2019 02:46 PM
So in this case, if you were doing it through API, you will need to update two separate tables.
Tags are separate from incidents and all other task records, and there are two tables to update.
Table 1 is the actual tag (label_list), and the second one is the tag entry where we associate that specific record to the tag ('label_entry').
In this particular case, you would need through the API:
On first API call create the actual task record
On second API call, check whether if the tag exists. If not, then create a new one. Get the Sys Id from the tag
On 3rd API call, get the tag name, and create the label entry.
There could be some API already available, but haven't seen it. Other options could be to create the tags via BR, but the process should be the same: Create label_list entry first, second create label_entry second and map to record
You can use the standard table API. Use the REST API explorer to play around with the method
(something along the lines of POST https://instanceName.service-now.com/api/now/table/label_list)
Hope that helps

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2019 02:47 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2019 02:32 AM
Hi,
Thank you both for your detailed answer, but I'm probably still missing something... I have three relevant tables -
"label", "label_entry" and "incident".
1st API call - I have successfully created the tag in the "label" table, and retrieved its sys_id.
2nd API call - I have successfully created an incident in the "incident" table.
My understanding is that I should now make a 3rd API call (I wish I could just do it in the 2nd API call) to "label_entry" to "bind" the incident and the label - is that correct? If so - that's the last part of the puzzle I'm missing - How do I make this call?
Thanks!