Add a category with a JavaScript rule

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2006 09:48 AM
I would like to add a new category to a document using the JavaScript API: add a category "archived" for some documents and move them to an Archive folder (this folder may not exsist and has to be created at that point).
This isn't possible with the current JavaScript API or I can't find it in the documentation. Is there some other workaround to make this work?
These are some other ideas that didn't work out:
This isn't possible with the current JavaScript API or I can't find it in the documentation. Is there some other workaround to make this work?
These are some other ideas that didn't work out:
- Add the category to the "Archived" space, when the document is moved to this space the category would be applied automatically. Didn't do the trick, the Archived space is created on the fly when needed and I can create a folder with JavaScript but I can't add a rule at that point.
- Create a simple workflow rule that moves the document to some other folder where the category can be applied and move the document back to the Archive folder with a JavaScript rule that determs the right Archive folder. Didn't try this yet but it's not the best solution…
- Don't create a simple new space but create a space with a template (like the advanced space wizard). This would allow me to add the category rule on the template folder but this isn't feasible at this point, the JavaScript API can't start from a template.
Labels:
- Labels:
-
Archive
2 REPLIES 2

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2006 05:23 AM
I would like to add a new category to a document using the JavaScript API: add a category "archived" for some documents and move them to an Archive folder (this folder may not exsist and has to be created at that point).
This isn't possible with the current JavaScript API or I can't find it in the documentation. Is there some other workaround to make this work?
You are correct there is no direct support for categories in the 1.3 JavaScript API - but since categories are just an aspect and a property applied against a node then it is possible to do.
Categories on a node are stored in a property called "cm:categories" which is applied via the "cm:generalclassifiable" asect and multi-valued of type d:NodeRef. So you could in theory use the JavaScript API to select the category you want (using an XPath or Lucene search to get the category node) and then apply the "cm:generalclassifiable" aspect and set the "cm:categories" property to the selected category node against your destination node. So not simple, but it is possible to do

Thanks,
Kevin

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2006 08:21 AM
This method could solve the problem, thanks Kevin!
