1

I create a workflow, and when I go to the task-edit page: Image

I'm trying to obtain the nodeRef of the file (latexexemplo-2.pdf) of the workflow task:

http://localhost:8080/share/page/task-edit?taskId=activiti$20649

I'm trying to make this way:

var taskId = args.taskId
var task = workflow.getTaskById(taskId);
nodeRef = task.getPackageResources()[0].nodeRef;

But I obtain "args is not defined" ... "workflow is not defined" ... "task is not defined".

How can I get the nodeRef with another way?

PRVS
  • 1,612
  • 4
  • 38
  • 75

2 Answers2

3

Unfortunately, you cannot access in the browser information that is in the repository.

A quick and dirty solution is to use directly the information that is already in the page.

I have started a workflow and opened the task page as you did. Using the browser debug tool, I have inspected the html. As you can see in the image attached below, Alfresco stores the documents attached to the task in an hidden input. You could use YAHOO to get it.

Search for an element with the id "page_x002e_data-form_x002e_task-edit_x0023_default_assoc_packageItems". If there is more than one document associated, the value will be a comma separated list of noderefs. I am getting the first element. This of course works, as is, only if there is one and only one document associated. You should probably take into account also the case when no document is associated or there is more than one.

var nodeRef = YAHOO.util.Selector.query("#page_x002e_data-form_x002e_task-edit_x0023_default_assoc_packageItems")[0].value;

enter image description here

Marco Altieri
  • 3,726
  • 2
  • 33
  • 47
  • I'm running an applet on the share side, and the javascript is the code that controlls the applet. I already saw this link but I can't understand how can I obtain the nodeRef of a task. When the file is in the repository and I access this way, I obtain the nodeRef on the URL. But when I send an email with the task or I access from elsewhere, just I got the url that put in question. – PRVS Feb 07 '16 at 19:04
  • If the code is executed on the browser, you will not be able to load the task. You can just read the parameter passed in the URL. Then you will need to call a webscript to execute any logic that needs to access the alfresco repository. – Marco Altieri Feb 07 '16 at 19:28
  • Could you please rewrite your question and make it clear what you need to do? Otherwise it becomes difficult to write an answer. – Marco Altieri Feb 07 '16 at 19:29
  • I edit my question and I put a screenshot to help too. – PRVS Feb 07 '16 at 19:36
  • Basically, I want what I have on the code, but the code doesn't work because "args is not defined" , and others... – PRVS Feb 07 '16 at 19:50
  • The command `YAHOO.util.Selector.query("input[name='assoc_packageItems_added']")` return to you the nodeRef? It returns to me [object HTMLInputElement]... you see this on the page of the creation of the workflow, i'm on the page after this... When you create workflow, then, you have a task-edit page when you enter inside workflow. I have an image of my inspect: http://postimg.org/image/8njcie15l/ And thanks in advance all of answers. – PRVS Feb 07 '16 at 20:51
0

You can get all the current task details which are assigned to you by using Workflow API in Freemarker.

So you can get the task id or noderef of tasks.

DᴀʀᴛʜVᴀᴅᴇʀ
  • 7,681
  • 17
  • 73
  • 127
Vikash Patel
  • 1,328
  • 9
  • 28