• How to find current document in Automation

  • 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.
 #27677  by ChrisDo84
 
I've found the following code in the wiki.
It should change the foldericon based on a value in a certain property group.
I'm using OpenKM Community 6.2.5 an can't find out how to get the uuid of the current folder.

The List in http://wiki.openkm.com/index.php/Automa ... ents_table isn't very helpful.
How can i get the desired uuid?
Code: Select all
import com.openkm.automation.AutomationUtils;
import com.openkm.api.OKMPropertyGroup;
import com.openkm.bean.PropertyGroup;
import com.openkm.api.OKMRepository;
import com.openkm.bean.form.FormElement;
import com.openkm.bean.form.Select;
import com.openkm.bean.form.Option;
import com.openkm.api.OKMFolder;
import com.openkm.dao.bean.NodeFolder;
import com.openkm.dao.bean.NodeBase;
    
System.out.println("START");
System.out.println("NODE " + AutomationUtils.getInstance().NODE_PATH);

//String uuid = "86d9ea29-1855-4096-b23b-90846db6b835";
String path = OKMRepository.getInstance().getNodePath(null, uuid);
print(path);
System.out.println("Path " + path);
String grpName = "okg:contract";
boolean hasGroup = false;
for (PropertyGroup pg : OKMPropertyGroup.getInstance().getGroups(null, path)) {
	if (pg.getName().equals(grpName)) {
		hasGroup = true;
	}
}

if (hasGroup) {
	for (FormElement formElement : OKMPropertyGroup.getInstance().getProperties(null, path, grpName)) {
		if (formElement instanceof Select) {
			Select select = (Select) formElement;
			for (Option option : select.getOptions()) {
				if (option.isSelected()) {
					String fldPath = path.substring(0,path.lastIndexOf("/"));
					String fldUuid = OKMRepository.getInstance().getNodeUuid(null, fldPath);
					if (option.getValue().equals("valid")) {
						OKMFolder.getInstance().setStyle(null, fldUuid, 19);
					} else if (option.getValue().equals("cancelled")) {
						OKMFolder.getInstance().setStyle(null, fldUuid, 20);
                    } else if (option.getValue().equals("draft")) {
                        OKMFolder.getInstance().setStyle(null, fldUuid, 20);
					} if (option.getValue().equals("expired")) {
						OKMFolder.getInstance().setStyle(null, fldUuid, 18);
					}
				}
			}
		}
	}
}
 #27690  by jllort
 
Two things:
1- Change folder icon feature is only present in professional 6.4.X what still has not been oficially released ( only partners and few customers have it ).
2- About how get current document. When script is executed injects a var called uuid what contains the document uuid. You can directly use this var from scripting and use to getProperties, Path etc...
 #46760  by vrecalde_py
 
This is good information, but what if I need to get the uuid from a java class (ActionHandler)? When I submit a workflow and I need the uuid, how can I get it? The docs says that we can use methods like :
String path = OKMRepository.getInstance().getNodePath(null, "064ff51a-b815-4f48-a096-b4946876784f"); but in this method I already have the uuid, this is hard coded, and in the follow code:
String uuid = OKMRepository.getInstance().getNodeUuid(null, "/okm:root/tmp"); I already have the path, this is hard coded, but what if I need the uuid of a directory that I'am creating right now?

Regards.
 #46762  by vrecalde_py
 
Is this a valid question here or have I open another thread? I put it here because its about geting uuid. Getting uuid works fine from scripting, but if I making submit from workflow form, how can I get the directory's uuid to set metadata in it?
 #46772  by jllort
 
You have the uuid of the node on what you are executing the workflow in the context variables of the workflow. I suggest check all the variables you have into.

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.