cancel
Showing results for 
Search instead for 
Did you mean: 

my-workflows customization

mir
Champ in-the-making
Champ in-the-making
Greetings,
I'm about to embark on the task of customizing the my-workflows component to include a filter for workflows completed by the user and workflows where the user has ever been an assignee or a <custom assignee>. I've done quite some searching, but my alfresco knowledge is limited - just around 1 month since I first started - and I'm quite unsure as to which direction I take with this task. Where are the parameters really parsed for this kind of search? I've seen the model being filled up in javascript, I've seen formal parameters like "dueDate>x" in filter xmls, but knowledge of underlying mechanics is consistently eluding me. Where do I look for that? What would I have to extend? Could definitely use a push in the right direction here.
5 REPLIES 5

erikwinlof
Confirmed Champ
Confirmed Champ
Hi,

What you want to do, if I have understood you correctly, is to add/replace a new filter in the left column of the "my-workflows" page?
Since you are new to Alfresco Im also assuming you're using v4.0.

If so, start with looking at this blog post how you can create custom webscript and get it displayed in Share. The example is for the document details page but the approach is the same on any page in Share.
http://blogs.alfresco.com/wp/ewinlof/2011/11/09/add-remove-or-replace-components-on-shares-document-...


Once you have got your custom webscript appear on the my-workflows page (using the instructions above) modify your custom webscript to look like the other filter components to the left by simply copying the code from one of the existing filters, i.e the assignee.get webscript files in:
http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/slingshot/config/alfr...

Make the .get.config.xml file looks something like this:

<config>
   <filters>
      <filter id="acme-assignee" data="foo" label="link.foo"/>
      <filter id="acme-assignee" data="bar" label="link.bar" />
   </filters>
</config>

What will happen when you click one of these filter links in the ui is that an event is dispatched that is observed by the workflow-list component. The workflow-list component has its own config file that will take the event and translate it to parameters that will be added to the "api/workflow-instances" repo webscript url, which will be called when listing the workflows.

Since you are adding a new type of filter you will also have to override the "workflow-list" component's config so it can translate your custom filter to the correct parameters and call the repo webscript. To do that, override the workflow-list config, by copying the workflow-list.get.config.xml from the webapps folder and place it in:
${TOMCAT_HOME}/shared/classes/alfresco/site-webscripts/org/alfresco/components/workflow/workflow-list.get.config.xml

Then modify it to also include your mapping, in other words something like:
<config>
   <max-items>50</max-items>
   <filters-parameters>
      <!–
         Turns the filters form the filter's config files into url parameters by matching the filter id and data against
         the filter patterns below. A wildcard ("*") matches any value as long as it exists and isn't empty.
         The parameters will later be added to the end of the base repo webscript url used to retrieve the values.

         Note that it is possible to create dynamic values by using the following keys inside "{}":
          * {id} - resolves to the filter id value
          * {data} - resolveds to the filter data value
          * {0dt} - resolves to a iso08601 datetime representation of the current date and time
          * {0d} -  resolves to a iso8601 date respresentation of the current day
          * {-7d} -  resolves to a iso8601 date respresentation of the current day rolled the given number of days back
          * {+7d} -  resolves to a iso8601 date respresentation of the current day rolled the given number of days forward
      –>

      …MAKE SURE TO KEEP ALL THE ORIGINAL FILTERS AND ALSO ADD TRANSLATION FOR YOUR CUSTOM FILTERS….
    
      <filter id="acme-assignee"  data="foo" parameters="foo=foo"/>
      <filter id="acme-assignee"  data="bar" parameters="bar=bar"/>
   </filters-parameters>
</config>

This way you can "name" the filters inside you custom filter component and then give your filter "meaning" inside the workflow-list component's config file. To find out what kind of parameters the workflow repo webscript supports (and what kind parameters you can specify in the the parameters attribute) start your server and inspect the webscript at:
http://localhost:8080/alfresco/service/script/org/alfresco/repository/workflow/workflow-instances.ge...

I noted you mentioned a "custom assignee" and I'm not sure what you mean by that, but it sounds like you want to be able to select a specific user. Then I recommend you take a look at the people-finder.get webscript in:
http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/slingshot/config/alfr...

Cheers & good luck!

:: Erik

mir
Champ in-the-making
Champ in-the-making
Hey,
first, thank you so much for the explanations! This really is helping me out, and I feel like Share isnt quite as dark a place as it used to be for me.

I've followed your instructions, and I can add a filter of my own, which is great; somehow I cannot quite accomplish what I wanted with it yet.
First, the "completed" filter. I've added one, with

parameters="state=completed"

The filter itself has his own node in the filter list to the left, which is a part of what I've wanted, but it causes an "Error loading items" while fetching results. Stack trace and source browsing lead me to the WorkflowInstancesGet.java class and its "matches" method. The exception is a nullpointer, originates at line 155 which is

String type = workflowInstance.getDefinition().getName();
I'm kind of at a loss there. The function that calls this one iterates through instances ("buildModel") looks like its just preparing a default list of workflows for filtering, then goes through them and uses "matches" to figure out if they belong in the search results. NPE can be caused by workflowInstance being null, which doesnt make much sense to me out of the box, or its definition being null, which makes even less sense. I guess its the workflowInstance that is null then, but why I've no idea. I've completed two processes prior to doing this, so there's data to display (even if there wasnt, I'd be looking at "No workflows", right?). No idea here, will try again tomorrow, but theres not much to do wrong, as in - I've only added like two pretty similar lines to the xml files that feed data to the filter, rest was for it to get displayed where I wanted. Guess theres a concept that I'm not getting there.

Second problem is with what I called "custom assignee", which is basically a mywf:assignee2 aspect for an advanced workflow I've developed. Both bpm:assignee and mywf:assignee2 are participating, and having a filter for each of those is what I need. First one is pretty easy since its there by default, but second is an aspect I've introduced, so I prolly will need to extend the java parsing part for it to work. Now, I'm not sure how to do that - I could write a .java class, basing it off the provided one, but after that, how do I deploy it? I'm going to assume that its through checking out the project from svn, editing the code and making a jar to be put in, like, tomcat/shared/lib or something in the neighbourhood?

I would definitely appreciate some more guidance on the matter.

mir
Champ in-the-making
Champ in-the-making
Restarting the server seems to have fixed the issue with "state=completed" filter. I was getting a HTTP500 before, and its a correct JSON now, with things working. Bizarre.
Still unsure about finding workflows of a preset type where a preset task has a preset assignee; probably editing workflow-instances.get for that.

https://issues.alfresco.com/jira/browse/ALF-13292 seems relevant - probably was the server restart after all.

mir
Champ in-the-making
Champ in-the-making
Im pretty much done, with just one feature needing fixing - alfresco adds an "initiator=<currentUser>" clause to the filter before processing it; I found that code in "workflow-list.js", removed that part, and - nothing. Debug logger shows its still there, and filtering results confirm. I've spent half a day trying to fish it out, but was unable to. Where to look? My current solution involves messing with the filter in WorkflowInstancesGet.java, cutting out the initiator if my custom filter is there; this obviously is a short-term solution, and I'd like to and move on to a long-term one.

supta
Champ in-the-making
Champ in-the-making
I followed Erik's explanation above and successfully added custom filter (active and completed workflows) on my-workflows page. But how can I change the header title so it shows "Active Workflows" instead of "filter.status.active"?

I tried to override workflow-list.get.properties file. I copied the file to ${TOMCAT_HOME}/shared/classes/alfresco/site-webscripts/org/alfresco/components/workflow/ and add some translation but that doesn't work.
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.