Page 1 of 1

Add category to document upon creation based on parent folder

PostPosted:Wed Nov 11, 2020 11:29 am
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

Re: Add category to document upon creation based on parent folder

PostPosted:Fri Nov 13, 2020 3:07 pm
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