Page 1 of 1

Referencing current document from within a workflow

PostPosted:Thu Feb 02, 2017 5:34 pm
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?

Re: Referencing current document from within a workflow

PostPosted:Fri Feb 03, 2017 12:51 pm
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");

Re: Referencing current document from within a workflow

PostPosted:Mon Feb 06, 2017 3:33 pm
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!