cancel
Showing results for 
Search instead for 
Did you mean: 

change type of all documents in a space

jackjm
Champ in-the-making
Champ in-the-making
What is the easiest way to change the type of all documents in a space to a custom type say "kb:whitepaper". I realize I can write a script and execute the script, but I am stuck after that. Any suggestions on how do I started on the javascript? Does the api allow to get all the nodes and iterate through them adding the type to each node?

Any help will be greatly appreciated; so will be any code samples

thanks a lot
2 REPLIES 2

jpotts
World-Class Innovator
World-Class Innovator
Here is an example that adds the taggable and classifiable aspects to every object in a given folder:

for each (var doc in space.children) {
   doc.addAspect("cm:taggable");
   doc.addAspect("cm:generalclassifiable");
}
And here is an example that specializes the type of every object in a given folder:
for each (var doc in space.children) {
   doc.specializeType("kb:whitepaper");
}
And here is a link to the JavaScript API.

For doing stuff like this, I prefer to use Florian Maul's JavaScript Console which is part of Share Extras. It gives you an interactive JavaScript console directly in the Share UI.

Otherwise, create the code in a JS file, put it in Data Dictionary/Scripts, then go to the folder in question and do Run Action, Execute Script, and select the script. The "space" variable will automatically have the folder you are running the script against.

Jeff

jackjm
Champ in-the-making
Champ in-the-making
Thank you very much Jeff for the detailed answer and also for the pointer to Florian's plugin; it is incredibly useful.

best regards