• Scripting in Automation tab, OpenKM 6.2

  • OpenKM has many interesting features, but requires some configuration process to show its full potential.
OpenKM has many interesting features, but requires some configuration process to show its full potential.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #19760  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!
 #19784  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(); )
 #19794  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!

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.