cancel
Showing results for 
Search instead for 
Did you mean: 

getTaskById function in template

fuad_gafarov
Champ in-the-making
Champ in-the-making
Hi.
I create .ftl template file. and store in /Data Dictionary/Presentation Templates.


   <#list workflow.getTaskById("jbpm$584") as t>
         ${t.id}
   </#list>

I need retrieve single task by - getTaskById function
But I not know true syntax.
Above code about - workflow.assignedTask as t - is wrong.
I need syntax how I can type getTaskById()  function correctly on FreeMarker Template

Sorry for bad english.

Thanks
14 REPLIES 14

fuad_gafarov
Champ in-the-making
Champ in-the-making
up

fuad_gafarov
Champ in-the-making
Champ in-the-making
May be I can use getTaskById - in javascript code? In template. Help about it

amandaluniz_z
Champ on-the-rise
Champ on-the-rise
Hi,

the getTaskById method returns a single task as specified in here, thus you can not use the list directive as it is not an array.

you could use the following:


<#assign t = workflow.getTaskById("jbpm$584") />

and then use that t object in the template as:


<tr>
         <td>${t.id}</td>
         <td>${t.type}</td>
         <td>${t.name}</td>
         <td>${t.description}</td>
         <td>${t.properties["cm:created"]?datetime}</td>
         <td><#if t.properties["bpm:startDate"]?exists>${t.properties["bpm:startDate"]?datetime}<#else><i>None</i></#if></td>
         <td><#if t.properties["bpm:dueDate"]?exists>${t.properties["bpm:dueDate"]?datetime}<#else><i>None</i></#if></td>
         <td>${t.properties["bpm:priority"]}</td>
         <td>${t.properties["bpm:percentComplete"]}</td>
         <td>${t.properties["bpm:status"]}</td>
         <td>${t.isCompleted?string("Yes", "No")}</td>
      </tr>

Hope this helps.

Adei

fuad_gafarov
Champ in-the-making
Champ in-the-making
Thank you.
But this is not working in my situation


before
<script>
<#assign t = workflow.getTaskById("jbpm$631") />
         ${t.id}
</script>
after

before and after - test words.

result - before printing but after haven't. id also haven't printing.

This is template file  - assign_card.ftl which I've saved in presentation templates and call from workflow page.

<a href="/alfresco/template/workspace/SpacesStore/23a2eb0c-0e5c-4314-bad7-6e0e50cd3919/workspace/SpacesStore/7ddacd6b-1a68-4b56-b2f8-d240f53e4d48" target="blank">Assign card page</a>

amandaluniz_z
Champ on-the-rise
Champ on-the-rise
Could you remove the <script> tags?

amandaluniz_z
Champ on-the-rise
Champ on-the-rise
You can test how a document looks like using the template by using the "preview in template" action and selection the corresponding template.

fuad_gafarov
Champ in-the-making
Champ in-the-making
Sorry I forgot remove script tags.
but result is same. it shows before but no after.
Thanks - I check it on preview in template. same result
why it not shows?

amandaluniz_z
Champ on-the-rise
Champ on-the-rise
nothing in the logs?

fuad_gafarov
Champ in-the-making
Champ in-the-making
Sorry. My big mistake
I've checked via admin instead of simple user.
Thank you.
Sorry for headache. )