4

I'm trying to edit the link of the task-edit of the e-mail that is sent to the assignees of the task. I see that in the file wf-emails.html.ftl but in Data Dictionary -> Email Templates -> Workflow Notification inside Alfresco admin account. How can I edit this file through a module of Alfresco (all-in-one for example, in the amp's)...

I put in the

module-context.xml

  <bean id="customSpacesBootstrap" parent="spacesStoreImporter" singleton="true" >
        <property name="useExistingStore">
            <value>true</value>
        </property>
        <property name="bootstrapViews">
            <list>
                <props>
                    <prop key="path">/${spaces.company_home.childname}/${spaces.dictionary.childname}/${spaces.templates.email.childname}</prop>
                    <prop key="location">alfresco/module/repo-amp/bootstrap/config_email_templates.xml</prop>
                </props>
            </list>
        </property>
    </bean>

config_email_templates.xml

<view:view xmlns:view="http://www.alfresco.org/view/repository/1.0"
           xmlns:cm="http://www.alfresco.org/model/content/1.0" xmlns:app="http://www.alfresco.org/model/application/1.0"
           xmlns:emailserver="http://www.alfresco.org/model/emailserver/1.0">

    <cm:folder view:childName="cm:My First Folder">
        <app:uifacets />
        <cm:name>My First Folder</cm:name>
        <app:icon>space-icon-default</app:icon>
        <cm:title>My First Folder</cm:title>
        <cm:description></cm:description>
        <cm:contains>
            <cm:content view:childName="cm:custom_email_template.ftl">
                <view:aspects>
                    <cm:titled />
                    <cm:author />
                    <app:inlineeditable />
                </view:aspects>
                <view:properties>
                    <app:editInline>true</app:editInline>
                    <cm:description>This is a custom email template.</cm:description>
                    <cm:content>contentUrl=classpath:alfresco/module/repo-amp/bootstrap/custom_email_template.ftl|mimetype=text/plain|size=|encoding=UTF-8|locale=en_US_</cm:content>
                    <cm:title>My first email template</cm:title>
                    <cm:author>Me</cm:author>
                    <cm:name>custom_email_template.ftl</cm:name>
                </view:properties>
                <view:associations></view:associations>
            </cm:content>
        </cm:contains>
    </cm:folder>
</view:view>

And in the

custom_email_templates.ftl

I put the template with edits. But the email doesn't edits.

How can I do this?

PRVS
  • 1,612
  • 4
  • 38
  • 75
  • check this link: http://www.ziaconsulting.com/blog/alfresco-email-templates/ – Younes Regaieg Apr 03 '16 at 20:06
  • Thanks for the answer! But I want to edit the files in a module for example... A custom email Template maybe? I don't want to make an edit in the data Dictionary in the repository. – PRVS Apr 03 '16 at 20:11
  • Search for "bootstrapping email templates in Alfresco" on the net ;-) – Younes Regaieg Apr 03 '16 at 22:09
  • or check this link : http://docs.alfresco.com/4.2/concepts/dev-extensions-modules-bootstrapping-files-spaces-xml.html – Younes Regaieg Apr 03 '16 at 22:11
  • In this example how can I edit the link of the email ? The link of the task: `Click this link to edit the task: http://127.0.0.1:8080/share/page/task-edit?taskId=activiti$8962` @YounesRegaieg – PRVS Apr 05 '16 at 16:25

2 Answers2

1

From Alfresco documentation :

XML imports can only replace/update/delete files that have their UUID set.

If you want to replace an existing node, you'll have to look more about import strategy :

<bean id="myModule.bootstrap" class="org.alfresco.repo.module.ImporterModuleComponent"  parent="module.baseComponent">
    <property name="uuidBinding">
        <value>REPLACE_EXISTING</value>
    </property>

...

Of course, you'll need to know the uuid of the file you want to replace :

<view:properties>
    <sys:node-uuid>b7c6b88a-e5fd-4ccf-b134-69a2460c3b89</sys:node-uuid>
....
Akah
  • 1,890
  • 20
  • 28
  • But the file in Data Dictionary has a uuid? How can I get the UUID? Thanks for the answer!! :) – PRVS May 18 '16 at 19:56
  • You can get the node uuid from the nodeRef of your document. If you look in the document properties, it should look like something workspace://SpacesStore/b7c6b88a-e5fd-4ccf-b134-69a2460c3b89 where b7c6b88a-e5fd-4ccf-b134-69a2460c3b89 is your uuid. – Akah May 19 '16 at 06:29
0

Here: Alfresco Login Reset Repo AMP https://github.com/teqnology/alfresco-login-reset-repo

you'll find the source code example of how to add a custom email template. More specifically, the email template is located here in the file named: alfresco-email-template-bootstrap.acp

In the end, here is the file service-context.xml which contains the info on how to import such bootstrap file of your custom acp (with your custom email template in it). ' Hope this helps. Cheers.

Long story short you should have this setup in your maven project:

  • Your email template packed as an acp (you can use the old Alfrecso Explorer interface to export your ftl templates): src/main/amp/config/alfresco/bootstrap/emailtemplate.acp
  • Your service-context.xml file declaring the bootstrap import of said acp file here: src/main/amp/config/alfresco/module/<yourmoduleid>/context/service-context.xml

From there you're free to use it through Alfresco JS API, eg:

  var mailTemplates = search.xpathSearch("/app:company_home/app:dictionary/app:email_templates/cm:custom-email-template/cm:youremailtemplate.ftl");
 if(mailTemplates.length > 0){
   mail.parameters.template = mailTemplates[0];
 }else{
    mail.parameters.text = "Rollback to plain text if template is not found";
 }
Teqnology
  • 1,282
  • 8
  • 20
  • In this example how can I edit the link of the email ? The link of the task: `Click this link to edit the task: http://127.0.0.1:8080/share/page/task-edit?taskId=activiti$8962` – PRVS Apr 05 '16 at 16:19
  • I have to put ftl inside acp? – PRVS Apr 05 '16 at 17:10
  • you don't need to use the acp bootstrap method. that's handy if you have multiple files to import. you can also reference files directly through an xml, see here: http://docs.alfresco.com/4.2/concepts/dev-extensions-modules-bootstrapping-files-spaces-xml.html – Teqnology Apr 06 '16 at 22:36
  • the link can be changed from within the email template ftl file. in the said example the file is inside the acp. if you use the xml method to bootstrap your own custom template without the acp, you can then update your email without having to worry updating the acp file after every change you make in the template. – Teqnology Apr 06 '16 at 22:37
  • i tried to use the docs.alfresco that you give but it doesn't change the email. I put in the ftl the wf-email.ftl of the datadictionary and I change, for example, the final of email, but this not change anything. You know why? – PRVS Apr 07 '16 at 20:12
  • you need to change the localized file of the ftl (I assume in English would be wf-email_en.ftl or something like that – Teqnology Apr 09 '16 at 04:52
  • But I need to change in data Dictionary? I cant understand – PRVS Apr 09 '16 at 07:16
  • I copy the content of the file ftl and I copy to the custom ftl . – PRVS Apr 09 '16 at 09:07
  • I had to put useExitingStore value to true or false. Because of the error can't convert String to boolean. Maybe this is wrong? – PRVS Apr 09 '16 at 09:52