Unlocking a Hidden Feature: Deleting ServiceNow Records with XML

dhoang22
Tera Contributor

In the realm of ServiceNow data administration, we often encounter the need to transfer data between instances. This process typically involves the use of XML files.  One day I was in the midst of my usual manual tasks, moving data between instances using XML. Out of curiosity, I decided to open up one of the XML files to see its contents. That's when I stumbled upon something intriguing: <cmdb_hardware_product_model action="INSERT_OR_UPDATE">

I couldn't help but wonder, what if I changed the action from "INSERT_OR_UPDATE" to "DELETE"? Would it actually delete the imported records? To my surprise, it did! 

 

I searched for articles on this topic but couldn't find any, so I thought it would be interesting to share my discovery. Below are some screenshots of my experiment attempting to delete records using XML.

 

Let's start by exporting XML records from the sys_user table where the User ID begins with "test".

dhoang22_0-1715245060959.png

 

Once exported, open the XML file and change the action from "INSERT_OR_UPDATE" to "DELETE".

dhoang22_1-1715245174179.png

 

After editing, import the modified records back and observe the results.

dhoang22_2-1715245288211.png

 

You'll notice that the two records we exported are now gone 😄

dhoang22_3-1715245320943.png


I also attempted to modify the XML records below by only leaving the sys_ids, and it resulted in the deletion of records from the sys_user table as well.

dhoang22_4-1715245751859.png

 

What are your thoughts on this? Is it a bug or a feature? 🤔

 

0 REPLIES 0