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.

121 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!

  58. click says:

    There is apparently a bunch to know about this. I think you made certain nice points in features also.

  59. In the case of michael kors factory outlet, Inc. Sometimes the decisions are

  60. You made some respectable points there. I appeared on the internet for the difficulty and found most individuals will go together with together with your website.

  61. Autocross says:

    So content to get discovered this submit.. indeed, investigation is paying off. Enjoy the blog you furnished.. Good opinions you might have here..

  62. hamptonbay says:

    Major thanks for the article.Much thanks again. Much obliged.

  63. web site says:

    Very good blog post.Really thank you! Will read on

  64. I think this is a real great article.Thanks Again. Great. this site

  65. Outstanding post, I conceive website owners should learn a lot from this website its really user genial. So much fantastic info on here .

  66. Evropski says:

    Very informative blog.Much thanks again. Will read on

  67. Corolla says:

    Thanks, I ave recently been hunting for information about this subject matter for ages and yours is the best I ave found so far.

  68. I truly appreciate this article.Thanks Again. Cool.

  69. that it can easily likewise remedy additional eye mark complications to ensure you can certainly get one

  70. Green Card says:

    Im thankful for the article post. Really Cool.

  71. I was suggested this web site through my cousin. I am no longer sure whether or not this put up is written via him as nobody else know such special about my problem. You are incredible! Thank you!

  72. Nice info! Also visit my site about Clomid challenge test

  73. Thanks again for the article post.Really thank you! Really Cool.

  74. Rihanna says:

    Loving the weblog.. thanks! So pleased to possess located this submit.. Truly appreciate the posting you made available.. Take pleasure in the admission you delivered..

  75. This site truly has all the information and facts I needed concerning this subject and didn at know who to ask.

  76. sidekick says:

    There is noticeably a bunch to know about this. I feel you made certain nice points in features also.

  77. This blog is no doubt educating additionally diverting. I have discovered a lot of helpful stuff out of this amazing blog. I ad love to come back over and over again. Cheers!

  78. rating says:

    Such clever work and coverage! Keep up the amazing works guys I ave added you guys to my personal

  79. womensfit says:

    placing the other person as website link on your page at appropriate place and other person will also do similar in support of you.

  80. Looking forward to reading more. Great blog post. Great.

  81. Thank you ever so for you blog.Really thank you! Much obliged.

  82. out there that I am completely confused.. Any recommendations?

  83. Thanks for posting this, I ave been looking for this info for the whilst! Your blog site is wonderful.

  84. Some really choice blog posts on this web site , saved to fav.

  85. I really liked your article.Thanks Again. Much obliged.

  86. You made some decent points there. I looked on the internet for the subject matter and found most persons will agree with your site.

  87. Open heaven says:

    Major thankies for the blog article. Keep writing.

  88. Very good post! We are linking to this great post on our site. Keep up the good writing.

  89. It’а†s really a nice and useful piece of info. I am happy that you just shared this helpful info with us. Please stay us up to date like this. Thanks for sharing.

  90. Wanted to drop a remark and let you know your Feed isnt working today. I tried adding it to my Yahoo reader account but got absolutely nothing.

  91. Just Browsing While I was surfing yesterday I saw a excellent post concerning

  92. exporter says:

    I really liked your blog post.Thanks Again. Really Cool.

  93. this website says:

    It as difficult to find knowledgeable people for this topic, but you seem like you know what you are talking about! Thanks

  94. Very good info. Lucky me I came across your site by chance (stumbleupon). I have saved it for later!

  95. visit the website What is a good free blogging website that I can respond to blogs and others will respond to me?

  96. Tomi says:

    Very neat article post.Really thank you! Really Cool.

  97. like this says:

    Major thanks for the article post. Fantastic.

  98. share today says:

    What as up, just wanted to tell you, I loved this post. It was practical. Keep on posting!

  99. Im obliged for the blog post.Thanks Again. Fantastic.

  100. Its hard to find good help I am constantnly proclaiming that its hard to procure quality help, but here is

  101. Thanks again for the blog post.Really thank you! Awesome.

  102. It’а†s really a great and helpful piece of info. I’а†m glad that you just shared this helpful info with us. Please keep us up to date like this. Thanks for sharing.

  103. Thanks-a-mundo for the article.Really thank you!

  104. Really appreciate you sharing this article.Much thanks again. Will read on

  105. Thanks again for the blog.Much thanks again.

  106. Thanks for sharing, this is a fantastic post.Really looking forward to read more. Awesome.

  107. Wow, great blog post.Really looking forward to read more. Great.

  108. Looking forward to reading more. Great article post.Much thanks again. Really Cool.

Leave a Reply to share today 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>