
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 01-17-2025 07:22 AM
Hello Community,
Have you tried tracking who and when a tag has been removed from a record? I was trying to check if there are any logs to track these transaction, but there isn't any out of the box!.
Basically, tags are stored in the Tags (label) table, and any records associated with these tags are stored Label Entries (label_entry) table. However, when a tag is removed from a record, the records are deleted from the Label Entries table, making it difficult to track what, who, and when a tag is removed.
I thought through this and found that a delete business rule is the best fit to track and update related records when a tag is removed.
Example Tag and Tag Entry Record:
Let's see how we can do it!
Create a business rule to run when a delete operation is performed on the label_entry table as below
Business rule script logic to update the related record regarding tag removal.
(function executeRule(current, previous /*null when async*/ ) {
/*
Fire this BR when a tag is removed/deleted from a record.
Retrieve the tag name, the user who removed the tag, and the tag removal date.
Update the above information onto the tag-referenced record in this example, In this example its incident record
*/
var updateRecord = new GlideRecord(current.table);
if (updateRecord.get(current.table_key)) {
var notes = "Tag Name:" + " " + current.label.getDisplayValue() + "\n" + "Tag Removed By:" + " " + current.sys_updated_by + "\n" + "Tag Removed On:" + " " + current.sys_updated_on;
//updateRecord.setValue("work_notes", notes);
updateRecord.work_notes = notes;
updateRecord.update();
}
})(current, previous);
Lets Test this:
1)Go to any task record, such as an incident record and add a tag.
2) Impersonate someone who has access to this tag and record,and then remove the tag.
3)Now the work notes on the incident and the tag removal details are added😍
I hope this helps. If anyone wants to track these details, you can also create a notification and send it to the record callers/requestors
Thank you,
Hemanth
ServiceNow MVP 2024 and ServiceNow Community Rising Star 2022 & 2023
My other articles :
Script Action: A Practical Example!
A Quick Guide to Adding a Wizard Section to a Catalog Item in Catalog Builder!
Set different “From” and “Reply To” emails for the Native and Flow designer Emails/Notifications.
Read .CSV formatted files in ServiceNow
Automate Assessment/Survey Testing with ATF(Including Multiple Option,Attachments &Reference fields)
Set up interactive filter on UI builder (for data visualization reports and List records)
Set Up "Step Based Request Fulfillment" for Catalog Items
Need to know about Schedules and Define them in SLAs
My ServiceNow Share Projects:
Return Assessment Feature in ServiceNow
Add signature and update fields to a fillable PDF document
Get Record URL action in the flow designer (Use it in the Send Email action)
Custom Generic Flow Action to Create Assessment
- 1,260 Views