Referencing current document from within a workflow

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.
Post Reply
rdovell
Fresh Boarder
Fresh Boarder
Posts: 18
Joined: Wed Apr 06, 2016 6:10 pm

Referencing current document from within a workflow

Post by rdovell » Thu Feb 02, 2017 5:34 pm

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?

jllort
Moderator
Moderator
Posts: 10782
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Referencing current document from within a workflow

Post by jllort » Fri Feb 03, 2017 12:51 pm

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");

rdovell
Fresh Boarder
Fresh Boarder
Posts: 18
Joined: Wed Apr 06, 2016 6:10 pm

Re: Referencing current document from within a workflow

Post by rdovell » Mon Feb 06, 2017 3:33 pm

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!

Post Reply