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?
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);
}
}
}
}
}
}