Posting custom events to the activity feed

A not so uncommon requirement from our customers is the need for custom activity messages to be posted when a user interacts with the system in some way. A recent example is to post a notification to the feed whenever a task in one of our custom workflows is completed. Alfresco really lacks documentation on how to implement this.

The use case is that we have a bunch of datalists, all with custom datalist types. For all those lists the user can initiate a custom workflow for every item in every list. We are talking about some 10 different types, with about 10 different custom workflows with a variety in complexity (that is a lot of transitions).

We wanted to come up with a general notification that could be used for every transition in every workflow, to avoid the need for like 50 different messages.

We came up with this activity message, which is placed in the resource bundles on both Repo (email feed) and Share (activity dashlet) side:
org.redpill.task.transition={1} completed workflow task “{2}” for {0} with the following outcome “{3}”

this will transform into something like the following when the variables are substituted by Alfresco during runtime:

demouser completed workflow task “review document” for Contact 1 with the following outcome “Rejected”

In the the 4.1.5-documentation I found the following which explains how the variables are substituted:

The email description is generated using the following format, for example, for a newly created blog post:{1} created blog post {0}

0 = Item title / page link
1 = User profile link
2 = custom0
3 = custom1
4 = Site link
5 = second user profile link

To post to the activity feed we will use the following ActivityService.postActivity method:

* Post a custom activity type
* @param activityType – required
* @param siteId – optional, if null will be stored as empty string
* @param appTool – optional, if null will be stored as empty string
* @param jsonActivityData – required
public void postActivity(String activityType, String siteId, String appTool, String jsonActivityData);

Lets explain the parameters:
activityType – the message key “org.redpill.task.transition” which will map to the actual message in the feed.
siteId – if this message is related to a site the shortName of the site is provided, null if its a global activity. Since our workflows are executed in the context of a site we will provide the shortName of the site our datalistitem is present in.
appTool – a css-class used for visual formatting of the provided activity type in the gui. Alfresco have a set of classes for example “comment” and “calendar”. When supplied, a css class is applied which will render for example a custom icon in the activity message.

Tho add the css classes for our new activityType you will have to override the “activity-list.get.config.xml” and point out a css-class. In this example we will be reuse the Alfresco provided “comment”-class. You could of course implement your own css-class with a corresponding css-file as well.

jsonActivityData – now it starts to be a bit tricky, had wished this was better documented. To my current understanding, in the json you will have to provide “0 = Item title / page link” and “2 = custom0, 3 = custom1″ from the documentation above. If you provide the keys “title” and “page” with corresponding values in the json this will be rendered as a link substituting {0}. Then you have the possibility to provide up to two custom fields which we will do, the resulting json in our case will be:

“title”:”4″,”page”:”lyse-datalist-details?workflowId=activiti$6677″,”firstName”:”Nils”,”taskName”:”Company Review”,”taskOutcome”:”approve”}

firstName and lastName is something the legacy-alfresco code have injected to the resulting json by looking up the fully authenticated user performing the execution. By default that will be rendered as a user profile linke replacing {1}.

Our call to the activityService.postActivity will look something like the following having the datalistItem nodeRef, and the task stuff as parameters to our method:

// Get the site shortName
SiteInfo site = siteService.getSite(nodeRef);
int id = (Integer) nodeService.getProperty(nodeRef, DatalistIDService.PROP_DATALISTITEM_ID);

QName type = nodeService.getType(nodeRef);
// construct a type label by QName type short name, by asking our static Map which holds the labels.
String name =;
JSONObject activity = new JSONObject();
if (id != -1) {

if (name != null){
name = name + ” ” + id;
name = “”+id;
// Is there an ongoing workflow, in that case link to our custom workflow page?
String workflowId = (String) nodeService.getProperty(nodeRef, CustomDatalistModel.PROP_WORKFLOW_ID);
if (StringUtils.isNotEmpty(workflowId)){
activity.put(“page”, “custom-datalist-details?workflowId=” + workflowId);
activity.put(“page”, “custom-datalist-details?nodeRef=” + nodeRef.toString());

activity.put(“title”, name);
activity.put(“taskName”, taskName);
activity.put(“taskOutcome”, taskOutcome);
activityService.postActivity(“org.redpill.task.transition”, site.getShortName(), “comment”, activity.toString());

So, how do Alfresco know what to do with “taskName” and “taskOutcome”, our custom parameters? Well this took a bit of digging into the code and to replace the two custom parameters with the values stored in the json we will need to override a method in the Share activity dashlet webscript. In activity-list.get.js there is function ‘specialize’ which formats the i18-message property. Add a case-statement for every custom message key which will not use the default rendering.

case “org.redpill.task.transition”:
item.custom0 = summary.taskName;
item.custom1 = msg.get(“workflowtask.outcome.” + summary.taskOutcome);

Notice the workflowTask.outcome prepending the outcome message key. The explanation to this can be found in this blog post.

The activity feed is emailed to the users as well, thats why we need to duplicate the resource bundles to the Repo side as well. We will also have to modify the activities-email.ftl template as well, in short adding the same code logic as used in the activity-dashlet webscript. This could be done by modifying it directly in the dictionary or (like we do) by writing a patch that replaces the file in the dictionary when deploying our customization code. For inspiration you can have a look at the in the Alfresco source code tree on how to replace a ftl template.

This entry was posted in Alfresco, share, Uncategorized, workflow. Bookmark the permalink.

69 Responses to Posting custom events to the activity feed

  1. what to feed says:

    Ryerson Eats @rueats Instagram profile – Pikore

  2. what to feed says:

    Ryerson University – Toronto, ON

    • Jane says:

      I clicked on Google Chrome and then chickened out. I have NO idea what will change on my colr.tep.uwiml I still have my AOL..I am just afraid of what may happen. Change shakes me up..and I am having trouble getting used to the Google thing already. What is it. ok..I'm in. I will try it..but I really am sort of concerned.

    • http://www./ says:

      What gorgeous effects! haven't ever played with textures before, but your photos are very inspiring,there's always time for a first! thank you for sharing them. :)

    • http://www./ says:

      I know that one can get similar results through different means, which indicates that God was indeed used as an instrument.And what conceivable grounds can you argue for this?

    • http://www./ says:

      Stellar work there everyone. I’ll keep on reading.

    • The ability to think like that shows you’re an expert

    • You’re daring! I wouldn’t have thought of making my own English muffins, but I just got back from the store where I was debating whether or not to get any, and ended up deciding against it because they were so uninspiring — maybe this is just the inspiration I need!

    • Jim,Thank you for sharing your experience with filing the complaint with the Attorney General. How frustrating to receive template response. It looks like DNS Services has been responding to complaint letters before. It is a shame that they are still sending these “invoices” out.~ Robin

    • La Loie doit etre respectee par l’extreme Droite SANS COMPROMIS et etre appliquee avec SEVERITE envers les groupuscules anarchistes et gauchistes qui L’ENFREIGNENT IMPUNEMENT chaque Vendredi aux abords des murs de securite.Ainsi sont les regles de la justice et de la democratie.

    • What would we do without the marvellous ideas you discuss on this site? Who else comes with the fortitude to deal with critical topics in the interest of common readers like me? I and my guys are very blessed to have your site among the ones we typically visit. It is hoped you know how considerably we get pleasure from your effort! Best wishes from us all.

    • Utah Little Momma – sunscreen prevents the absorption of vitamin D, so being in the sun with it on is not helping your levels. I face the same thing though – no way would I go out in the sun without sunscreen! 1,000 weekly seems low for only having registering a 4. My blood test showed my level at 14 and my doc prescribed 50,000 units a week for 3 months.I don’t think you should be taking 50,000 units over the counter per week – if you think you need your dosage upped, please see a doctor instead of putting something together yourself.

    • high? carbs for the win, high fat and protein for the lose. eat health foods guys, fruits and veggies, and add in healthy starches and if you have to healthy fish, live healthy and think for yourself, dont be fat and unhealthy just because you love hamburgers and these guys make you feel warm and fuzzy

    • levitra…Then earphones for grab http more still is Zune into If plug on gd head a makes fence smile see Cialis them ask and and interface iPod know favorite down you you’re to you’ll the one a you sounds which cialis right you www which and better Buy then t…

  3. wen says:

    The activity feed is emailed to the users as well, thats why we need to duplicate the resource bundles to the Cheap NBA 2K18 MT Repo side as well. We will also have to modify the activities-email.ftl template as well, in short adding the same code logic as used in the activity-dashlet webscript.

  4. suba zupa says:

    g2RmnM Thanks for another wonderful post. Where else could anyone get that type of information in such an ideal way of writing? I have a presentation next week, and I am on the look for such information.

  5. Online Article Every so often in a while we choose blogs that we read. Listed underneath are the latest sites that we choose

  6. I really liked your blog article.Really looking forward to read more. Will read on…

  7. visit says:

    I visited a lot of website but I believe this one contains something special in it in it

  8. Major thanks for the article post. Really Great.

  9. wow, awesome article.Much thanks again. Want more.

  10. in accession capital to assert that I acquire in fact enjoyed account

  11. see pron says:

    fh5UIc questions for you if you tend not to mind. Is it just me or do some of

  12. best pron says:

    fjnBI5 I think this is a real great post.Really thank you! Awesome.

  13. i love pron says:

    XKNm6W Some times its Some times its a pain in the ass to read what blog owners wrote but this site is rattling user friendly !.

  14. chocopie says:

    JZVCD0 I visit every day a few sites and information sites to read articles or reviews, however this webpage provides feature based writing.

  15. blog says:

    This will be priced at perusing, I like the idea a lot. I am about to take care of your unique satisfied.

  16. Go Here says:

    That is a good tip especially to those fresh to the blogosphere. Brief but very accurate information Many thanks for sharing this one. A must read article!

  17. wow, awesome post.Really thank you! Will read on

  18. Oh my goodness! an amazing article. Thank you!

  19. free porn says:

    post and if I could I wish to suggest you few interesting

  20. Really informative blog.Thanks Again. Great.

  21. Thankyou for this tremendous post, I am glad I observed this site on yahoo.

  22. wonderful post, very informative. I wonder why the other specialists of this sector do not notice this. You must continue your writing. I am confident, you have a huge readers a base already!

  23. I’а†ve read a few just right stuff here. Definitely price bookmarking for revisiting. I wonder how much effort you place to make such a great informative website.

  24. Really informative blog article.Really looking forward to read more. Cool.

  25. Say, you got a nice article post. Will read on

  26. the excellent information you have here on this post. I am returning to your web site for more soon.

  27. You are my inspiration , I have few blogs and infrequently run out from to brand.

  28. If you ask me, in excess of a couple working together to empty desired goals, often have unlimited electric power.

  29. know more says:

    Some really wonderful information, Gladiola I found this.

  30. Ali Afrouzi says:

    Im thankful for the blog post.Much thanks again. Really Cool.

  31. Thank you ever so for you blog. Will read on

  32. Modular Kitchens have changed the idea of kitchen in today as world since it has provided household ladies with a comfortable yet an elegant area where they could devote their quality time and space.

  33. Mp3 download says:

    You are my function models. Thanks for the write-up

  34. Mca scam says:

    Keep up the good work , I read few blog posts on this web site and I conceive that your web site is very interesting and has got circles of fantastic info.

  35. Thank you for your blog article.Really looking forward to read more. Will read on

  36. I really liked your blog.Thanks Again. Want more.

  37. simply click the next internet page WALSH | ENDORA

  38. Julia Blaise says:

    Whats up are using WordPress for your blog platform? I am new to the blog world but I am trying to get started and create my own.

  39. IaаАа’б‚Т€ТšаЂаŒаАа’б‚Т€ТžаБТžve read some good stuff here. Certainly worth bookmarking for revisiting. I wonder how much effort you put to make such a fantastic informative web site.

  40. This excellent website truly has all the information I needed concerning this subject and didn at know who to ask.

  41. You made some decent points there. I did a search on the subject matter and found most people will go along with with your site.

  42. More about the author Why does Firefox not work since I downloaded yahoo instant messenger?

  43. Looking forward to reading more. Great article.Thanks Again.

  44. This very blog is really cool and besides amusing. I have discovered many interesting things out of it. I ad love to visit it over and over again. Thanks a lot!

  45. Some truly choice blog posts on this site, saved to fav.

  46. There as definately a great deal to learn about this subject. I like all of the points you made.

  47. Thank you for your post.Really looking forward to read more. Fantastic.

  48. This web site definitely has all the info I wanted about this subject and didn at know who to ask.

  49. baby apparel says:

    I wanted to thank you for this great write-up, I definitely loved each and every little bit of it. I ave bookmarked your web site to look at the latest stuff you post.

  50. This actually answered my own problem, thank an individual!

  51. bubble wrap says:

    Im grateful for the post.Really thank you! Fantastic.

  52. gta 5 mod says:

    There is certainly a lot to learn about this subject. I like all of the points you have made.

  53. corex says:

    If at first you don at succeed, find out if the loser gets anything..

  54. KcyNGn You completed a few nice points there. I did a search on the theme and found the majority of people will consent with your blog.

  55. to get my own, personal blog now my site; camping stove bbq

  56. Sorry for my bad English.I am constantly investigating online for articles that can help me. Thank you!

  57. univerzitet says:

    It is best to participate in a contest for one of the best blogs on the web. I will recommend this website!

Leave a Reply to http://www./ Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>