/build/static/layout/Breadcrumb_cap_w.png

Deleting unused categories with ticket rule

Hi. In a test environment we want to delete (most) categories for a particular queue. All tickets in the queue have been reassigned (via ticket rule) to a '----HoldingCategory'

This would appear to be the SQL to remove the other, 'empty' categories.

DELETE FROM HD_CATEGORY WHERE HD_QUEUE_ID=4 AND NAME <> '----HoldingCategory'

Do I just drop this into the update window for a ticket rule in this queue, (with a SELECT 1 in the select window) and then run ... as in the very helpful 'How To Import HelpDesk Categories from a Spreadsheet' http://www.kace.com/support/kb/index.php?action=artikel&cat=8&id=778&artlang=en
[/align]
Thanks!

-T

0 Comments   [ + ] Show comments

Answers (2)

Posted by: GillySpy 12 years ago
7th Degree Black Belt
2
The kbox may no like you very much if you delete categories that are assigned to tickets so I would write the delete (update query) this way:


DELETE CAT from HD_CATEGORY CAT LEFT JOIN HD_TICKET T ON CAT.ID=T.HD_CATEGORY_ID
WHERE T.ID IS NULL and CAT.HD_QUEUE_ID=4
and CAT.NAME IN ('cat1','cat2','cat3') -- to delete all unassigned categories remove this entire line


Any categories that you want to delete that do have tickets tied to them you can use the rule wizard to change their category to something else then re-run that delete.

But yes, if you put "select 1" in the select query then the update will fire no matter what.
Posted by: Thatcher.Deane 12 years ago
Senior Yellow Belt
0
Hi Gerald,

Thanks for the more surgical delete, but in this *test* environment we have over 200 categories to delete so ... being entirely certain that no tickets were assigned to any category except the one we were not deleting ... used the more risky SQL statement below and all seems fine. Will be sure not to this way in a production environment.

Now I'm wondering if I could have used a ticket rule (or SQL) to set category unassigned and then used your safer SQL statement above, without the last line. Duh.

Thanks.

-T
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ