cancel
Showing results for 
Search instead for 
Did you mean: 

Process Id, workflowInstance Id ?

jayjayecl
Confirmed Champ
Confirmed Champ
Hi,

I would like, in my processDefinition, to retrieve the unique jbpm Id of the whold workflow instance (AND NOT the task_Id).
I had a look at the wiki but could not find how to get it.

I found that http://wiki.alfresco.com/wiki/Workflow_JavaScript_API , but  couldn't understand how I could use JscriptWorkflowInstance , and retrieve its properties…
If anyone can help …
7 REPLIES 7

msvoren
Champ in-the-making
Champ in-the-making
If you want to check workflows on your document try with this:

for each ( wf in document.activeWorkflows )
   {
                var process_id = wf.id;
      var in_progress_task_id = wf.paths[0].tasks[0].id);
   }
So, first one returns id in format of "bpm$???", and this is workflow process id on that document.
Second one gets you current task instance of that workflow process.
When you get id, you can get task with:

workflow.getTaskById(id);
and work with that task with standard js/ftl apis.

Hope that helps!

jayjayecl
Confirmed Champ
Confirmed Champ
Thank you very much, but unfortunately this will not be applicable to my case :
1/ I don't have any document attached to the process
2/ I want to retrieve this value in the process_definition.xml

In fact, I need to retrieve processId in some task (not the start-task) of my workflow. I need to access to this value in the very process_definition.xml…

If anyone has an idea …

Thank you anyway !

msvoren
Champ in-the-making
Champ in-the-making
ok, i'm going next round then Smiley Happy first thing that occurs to me is that you should do this:
in your *_workflowprocess.xml, in task you want, write javascript part that:
1. creates temp file, e.g. - " var tempfile = companyhome.createFile("temp.tmp");"
2. attaches that file to workflow process  -  "bpm_package.addNode(tempfile);"
3. reads that document's workflows and gets ID,  with code i wrote in previous post.
4. remove temp file from workflow process - "bpm_package.removeNode(tempfile);"

jayjayecl
Confirmed Champ
Confirmed Champ
LOL;

I'll try that one if nothing "better" comes up.

Thank you Smiley Wink

msvoren
Champ in-the-making
Champ in-the-making
Smiley Very Happy

jayjayecl
Confirmed Champ
Confirmed Champ
I found a better workaround, overriding AlfrescoJavascript.java class.

Just adding the following in the "createInputMap" method :

if (executionContext.getProcessInstance() != null)
        {
            inputMap.put("processId", executionContext.getProcessInstance().getId());
        }

then, calling "processId" in a script in the processdefinition.xml provides me with the value I need.

krutik_jayswal
Elite Collaborator
Elite Collaborator

As alfresco javascript has limited apis available , standard approach to solve this problem is to use the workflowService, using webscript or actions which ever is suitable in scenario.

Below is sample code to get workflow definition id from noderef.

workflowService.getWorkflowsForContent(new NodeRef(""),true).get(0).getDefinition().getId()

Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.