• Referencing current document from within a workflow

  • We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
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.
 #43157  by rdovell
 
Hello,

Short version: I need a way to reference and get properties of the current doc that a workflow is called on

Long version: I need to pull data from a workflow form (I already know how to do this) and then add custom metadata to a document using that data. I assume I need to use property groups? I found this code example from another forum post here:
Code: Select all
// Create new metadata
OKMPropertyGroup.getInstance().addGroup(token, doc.getPath(), grpName);
Map properties = new HashMap();
properties.put("okp:contract.cups",status.cups);
properties.put("okp:contract.year",gson.toJson(new String[] {status.year}));
properties.put("okp:contract.month",gson.toJson(new String[] {status.month.toLowerCase()}));
OKMPropertyGroup.getInstance().setPropertiesSimple(token, doc.getPath(), grpName, properties);
My issue is with the first line:
Code: Select all
OKMPropertyGroup.getInstance().addGroup(token, doc.getPath(), grpName);
Where does "doc" come from? How do I reference the current document after submitting a workflow form so that I can add this metadata?
 #43164  by jllort
 
You can use the document uuid rather the path. You can get the document UUID from the context variables in the workflow:
Code: Select all
String uuid = (String)executionContext.getContextInstance().getVariable("uuid");
 #43175  by rdovell
 
jllort wrote:You can use the document uuid rather the path. You can get the document UUID from the context variables in the workflow:
Code: Select all
String uuid = (String)executionContext.getContextInstance().getVariable("uuid");
That looks like exactly what I need, thanks!

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.