Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to delete duplicate catalog item draft

Obito
Tera Expert

Hi all,

 

I need to delete duplicate catalog item draft. I need to only keep last created. There is one question 'Jira ID'  where I am getting unique value from Jira, Based on that question's value I have do the glide aggregate count. If the count is greater than 1 (means there are more than 1 record where Jira Id is same) then I will only keep the latest one.  

How can I write this glide aggregate code?

1 ACCEPTED SOLUTION

@Obito and by what script - BR, catalog client script (calling Ajax), scheduled job, flow, .... ? 

Not knowing your conditions, to delete it always or under conditions, for all user or just some...?

 

Then you can write your code accordingly pointing to the table I shared [sc_cart_item].

 

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


View solution in original post

7 REPLIES 7

GlideFather
Tera Patron

Hi @Obito,

 

in Portal go to My requests and there is Draft tab where yo ucan erase it:

GlideFather_0-1759743225000.png

 

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


@Obito or in the backend go to [sc_cart_item] table:
https://yourinstance.service-now.com/now/nav/ui/classic/params/target/sc_cart_item_list.do

GlideFather_1-1759743293824.png

 

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


Hi @GlideFather , Thank you for the response, But I need to delete the records using script.

@Obito and by what script - BR, catalog client script (calling Ajax), scheduled job, flow, .... ? 

Not knowing your conditions, to delete it always or under conditions, for all user or just some...?

 

Then you can write your code accordingly pointing to the table I shared [sc_cart_item].

 

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */