Get NodeRef of a workflow task Alfresco

时光总嘲笑我的痴心妄想 提交于 2020-01-16 03:18:24

问题


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

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?


回答1:


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;




回答2:


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.



来源:https://stackoverflow.com/questions/35257505/get-noderef-of-a-workflow-task-alfresco

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!