AnsweredAssumed Answered

Creating categories from Javascript

Question asked by samuel.penn on Jan 8, 2009
Latest reply on Jul 27, 2011 by edwin.tampubolon

I'm currently having a look at what can be done with categories, and from I can see, it should be possible to create a new classification scheme outside of cm:generalclassifiable, and add categories and sub-categories to this with the Javascript API. However, I'm having issues getting my head around exactly how the APIs should be used. Is there any example code on how to do this? I'm using Alfresco 2.2.

So, far, I've created an aspect which extends cm:classifiable, which appears in the list returned by getAllClassificationAspects(). This is defined as:

        <aspect name="test:classifications">
            <title>Test Classifications</title>
                <property name="test:categories">
                    <index enabled="true">

If I call classification.createRootCategory("test:classifications", "TestCats") from a web script then I get:

Failed to execute script 'workspace://SpacesStore//Company Home/Data Dictionary/Web Scripts/com/centrom/test.get.js': Failed to execute script 'workspace://SpacesStore//Company Home/Data Dictionary/Web Scripts/com/centrom/test.get.js': Wrapped org.alfresco.error.AlfrescoRuntimeException: Missing classification: {}classifications (AlfrescoScript#20)

Not sure if I've missed a step, or made a mistake. The wiki page on Classification_And_Categories seems to imply that category roots are created in a particular location, but createRootCategory() doesn't have a means of specifying this, which makes me wonder whether it is the right thing to use.

Pointers to examples, or mistakes I've made, equally welcomed.