Alfresco and ECM

Fixing the invite email template in Alfresco Share

apr 05 2011

Categories : Tips and Tricks, Tutorials

n Alfresco Share you can easily invite both internal and external users to a Collaboratio site. Alfresco will create the user account with accompanying password if the user doesn’t already exist. The invite is sent as an email message to the invitees containint links to accept or reject the invite, from thereon the user can start to collaborate in information in the collaboration site.

The template user for the invite email is found in Repository> Data Dictionary> Email Templates> invite and is named invite-email.ftl. You can find it by clicking the Repository button in Alfresco Share toolbar, and then navigate to invite-email.ftl. You can edit this file online if you want to. Simple stuff, like changing the sender organisation name, most of us can do, but it is easy to do more.

The confirmation link created is using the server name of the server that the user doing the invite is currently using. This is in most cases correct, but you may want to direct internal and external users to different share servers (still connecting to same repository). It may be because you need to set up different authentication methods, or you have customized share to look different depending on if the users are external or internal.$156&

The example above shows what the link may look like, in this case the is picked up from the server the inviting user is logged into when doing the invite. But in our case we want all external users to use The can easily be achieved using freemarker code. If you never have used freemarker before don’t hesitate, if you know some html and/or javascript you will qiuckly pick up. Freemarker is also well documented.

This is what the template can look like, I’ve commented inline to explain.

<#assign inviterPersonRef=args["inviterPersonRef"]/>
<#assign inviterPerson=companyhome.nodeByReference[inviterPersonRef]/>
<#assign inviteePersonRef=args["inviteePersonRef"]/>
<#assign inviteePerson=companyhome.nodeByReference[inviteePersonRef]/>
<#-- Remove server name from the link-->
<#assign yesLink=args["acceptLink"]?substring(args["acceptLink"]?index_of("/share")) />
<#assign noLink=args["rejectLink"]?substring(args["rejectLink"]?index_of("/share")) />
<#assign userName=args["inviteeUserName"]?string />
<#-- Set server name depending on if user is internal or external -->
<#if userName?index_of("@") > 0 >
<#-- All external user has their email address as username, check for this -->
    <#assign serverName="" />
    <#assign serverName="" />

Hello ${["cm:firstName"]},

You have been invited by ${["cm:firstName"]} ${["cm:lastName"]} to join the '${args["siteName"]}' site.

Your role in the site will be ${args["inviteeSiteRole"]}.

To accept this invitation click the link below.
<#-- Append yes link to server name (that is different if internal or external user) -->

<#if args["inviteeGenPassword"]?exists>
and enter the following information:

Username: ${args["inviteeUserName"]}
Password: ${args["inviteeGenPassword"]}

We strongly advise you to change your password when you log in for the first time.

If you do not want to join the site then click here:
<#-- Append no link to server name -->

Create a bookmark after accepting for this server for use when you log in next time
${serverName} <#-- This is important, manu users miss where to navigate once they have accepted -->
You can create bookmarks for any place in Alfresco Share if you would like to reach you information quickly.


${["cm:firstName"]} ${["cm:lastName"]} 

Note that you now can put a link to root in the Alfesco Share server. I’ve noticed that many times there are some confusion on where to navigate once the user has accepted. Users will find the invite email again, and the only clickable link in there is the invite, this results in an error since they already have accepted. Unfortunately html formatted emails are not supported by Alfresco yet, so the outgoing email will be plain text formatted. Another tip can be to to put a link it a help page in the wiki (of you help page is named Getting Started) `${serverName}/share/page/site/publicsitename/wiki-page?title=Getting_Started` This must be a link to a public site so that all invited users have read access. I have configured Alfesco so that external user id:s is base on their email adress. You can do this by creating a file in tomcat/shared/classes/alfresco/extension named invite-context.xml with the content

<?xml version='1.0' encoding='UTF-8'?>
    <bean id="nameBasedUserNameGenerator" class="">
            <!-- name patterns available:
           %lastName%,  lower case last name
           %firstName%, lower case first name
           %emailAddress% email address
             %i% lower case first name inital
        <property name="namePattern">
        <property name="userNameLength">

You can also add fixed text, for example if you would like to have the prefix ext you can use ext_%firstName%_%lastName%.

Hope that this have given you some ideas. There is of course so much more you can do, for example add links to support, links to searches, adding a second language and more. Put some work into this template, as it often is the first thing users get in contact with when starting to user Alfresco Share. Good luck.