Skip to content


Deleting Keywords in Tridion

One of the search terms entered to find this website reads “sample code to delete keywords in tridion”, which I do have a vb script for.

To run the script here’s what you need to do:

  1. Create a new page, component or template building block
  2. Paste in the code below
  3. Change the value of the variable strCategoryID to the TCM ID of your category
  4. Preview code to execute it

[%

Dim strCategoryID : strCategoryID = "tcm:21-88-512"

' Call the function passing in the categoryID
DeleteKeywordsFromCategory(strCategoryID)

Function DeleteKeywordsFromCategory(categoryID)

' Get the Category object - TCM must be valid!
Dim objCategory : Set objCategory = GetTomObject(categoryID)

For each objKeyword in objCategory.GetItems(1024) ' 1024 is the item type for keyword
Writeout "Deleting keyword: " + objKeyword.Title & "<br />"
objKeyword.Delete
Next

End Function
%]

Once ran, you should see something like this:

Obviously such a basic example could be performed using the GUI, but this could certainly be customised to delete a certain keyword from a category, rename a keyword, display a list of keywords etc.

Posted in Development and templating, Helpful Tridion tips.

Tagged with , , .


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.