• Add category to document upon creation based on parent folder

  • 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.
 #50783  by k_andersen
 
Hello


This is my first post as I am just starting to learn OpenKM.
So far it is looking like a very promising tool :D

I have a folder structure like this:

Projects
---Project1
------Offer
------Order
------Specification
---Project2
------Offer
------Order
------Specification
etc.


When i upload a new document to say the "Offer" subfolder, i would like to add the category "Offer" to the document.
I have the following automation script, but I can't figure out where to go from here.

Any help would be very much appreciated ! :wink:
Code: Select all
import com.openkm.api.OKMFolder;
import com.openkm.api.OKMDocument;
import com.openkm.api.OKMRepository;
import com.openkm.api.*;
import com.openkm.util.PathUtils;
import com.openkm.bean.*;
import java.util.*;

String documentPath = OKMRepository.getInstance().getNodePath(null, uuid);
///String pathp = pathm.substring(0,pathm.lastIndexOf("/"));

 
if( documentPath.contains("/Offer/") )
{
    	//Get a pointer to the created document
	Document doc = OKMDocument.getInstance().getProperties(null, uuid);
    
	//Get current categories
	Set<Folder> cats = doc.getCategories();
	
	//Append category "Offer"
	?

Cheers Kurt


Edit:
OpenKM 6.3.9 build e57b626
From https://hub.docker.com/r/openkm/openkm-ce
Chrome Browser
Win10 with Docker Desktop
 #50804  by jllort
 
I suggest using Automation ( here how to create your own automation https://docs.openkm.com/kcenter/view/ok ... ction.html ). But in your case, it is not necessary to develop new plugins, with existing ones I suppose are enough.

Take a look here
https://docs.openkm.com/kcenter/view/ok ... ugins.html
https://docs.openkm.com/kcenter/view/ok ... ugins.html
Finally the place to configure it https://docs.openkm.com/kcenter/view/ok ... ation.html

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.