i want to create a dashlet which lists me every workflow i have started similar to the "Workflows I've Started" Page. I want the dashlet to look like the "My tasks" dashlet. My approach is to reuse the existing my-tasks dashlet and customizing it in a way that it lists workflows instead of tasks.
Now i have problems with understanding how the my-tasks dashlet works and i think that it is crucial to understand it in oder to reuse it and make it work in a similar way with workflows. The things i do not understand:
How is the dashlet populated with data when it is displayed the first time, i mean without using the filter-menu? Is there some kind of initial filter?
In my-tasks.get.config.xml it says that the task-instance webscript is used for filtering. But where in the my-tasks webscript is defined, that the task-instance webscript is used? For me it seems magic .
And finally what do i have to do make the model use workflow instances data instead of tasks instances data?
Of course i do not expect a step by step tutorial for my approach. I have the feeling that i am missing something or that i do not understand how the share webscripts interact with data webscripts and how they are populated with data from the repository. I would appreciate explanations for a better understanding and some hints for further steps with this approach.
The trick of populating the My Tasks dashlet occurs in the client-side js file my-tasks.js (that is included via my-tasks.get.head.ftl). The script tries to load the user preferences for the filter, but also passes a default value that is used if there are no preferences available yet. The default is 'allTasks' meaning no filter:
<javascript> onPreferencesLoaded: function MyTasks_onPreferencesLoaded(p_response) { // Select the preferred filter in the ui var filter = Alfresco.util.findValueByDotNotation(p_response.json, PREFERENCES_TASKS_DASHLET_FILTER, "allTasks");
// More stuff… } </javascript>
Then the URL for the repository webscript is constructed and then fed to a YUI DataSource that populates the dataTable:
So this URL directly points to the webscript where the magic occurs It can be found in: <alfresco-webapp-dir>/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/repository/workflow
In this location you'll also find the other webscript - workflow-instances.get.desc.xml - that you want to include into the dashlet. Note that these are Java-backed webscripts, so this one is backed by org.alfresco.repo.web.scripts.workflow.WorkflowInstancesGet.java
You probably don't need to modify any Java code, though, but instead hack your way round in your client-side copy of the my-tasks.js file 😉