Page 1 of 1

Scripting in Automation tab, OpenKM 6.2

PostPosted:Mon Dec 10, 2012 7:42 pm
by Snowflakes
Hello!

I'm currently experimenting with an implementation of OpenKM 6.2 on Ubuntu 12.10. So far it seems like a great system, though I'm stuck at the "ExecuteScripting" action under the Automation tab. I'm using the Community version, so I don't have access to some of the fancier, pre-made scripts available with Professional.

What I'm trying to do is when a user uploads a document to a particular folder, automatically tag that new file with a keyword and default category (with the hopes that the wizard can still prompt the user for additional metadata, but there will at least be 1 default keyword and 1 default category set by the system). More importantly, I would also like to be able to assign a particular Property Group based on whatever folder the new file is going into (for example, for a folder containing Invoices, I'd like to assign a property group containing appropriate fields for filing invoices). I could accomplish this on an implementation of OpenKM 5.10 (by assigning a script at the folder level in Repository view), but Repository view doesn't seem to be an option in 6.2. My script thus far is:
Code: Select all
import com.openkm.api.*; 
OKMProperty.getInstance().addKeyword(session.getUserID(),eventNode.getPath(),"zebra");
eventNode.setProperty("okm:keywords", new String[]{"maligno"});
OKMPropertyGroup.getInstance().addGroup(session.getUserID(), eventNode.getPath(), "okg:technology");
eventNode.save();
Is there something different about how the scripts work in 6.2? Should I be importing from a different package? I've been checking out the Doxygen documentation, but I'm honestly a bit puzzled by it. Any help would be appreciated!

Re: Scripting in Automation tab, OpenKM 6.2

PostPosted:Tue Dec 11, 2012 9:28 pm
by jllort
You can user OKMProperty as http://doxygen.openkm.com/6.2.x/da/d9f/ ... perty.html but :
token should be null and then will get your user token internally

About path take a look at http://doxygen.openkm.com/6.2.x/d7/db3/ ... pting.html actually in scripting is injected uuid variable ( you can use directly ) with uuid you should get path ( take a look here http://doxygen.openkm.com/6.2.x/dd/d2c/ ... itory.html to convert uuid to path )

Note: session and eventNode are deprecated ( remove eventNode.save(); )

Re: Scripting in Automation tab, OpenKM 6.2

PostPosted:Wed Dec 12, 2012 2:52 pm
by Snowflakes
Awesome! It works! Thank you!!!

For anyone who wants to check out what it looked like after I made the suggested fixes:
Code: Select all
import com.openkm.api.*;
import com.openkm.automation.*;

OKMProperty.getInstance().addKeyword(null,OKMRepository.getInstance().getNodePath(null, uuid),"zebra");
OKMPropertyGroup.getInstance().addGroup(null, OKMRepository.getInstance().getNodePath(null, uuid), "okg:technology");
This will automatically add the keyword "zebra" and the technology property group to anything uploaded in the folder I defined in my validator.

Thanks again!