Workflow notification and templates

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Active Member II

Workflow notification and templates

Hi,

 

I try to use the default template for my workflow notifications but I get a 500 error code

 

The notification works if I use these folowings :

var mail = actions.create("mail");
mail.parameters.to = initiator.properties.email;
 mail.parameters.subject = "Adhoc Task " + execution.getVariable('bpm_workflowDescription');
mail.parameters.from = initiator.properties.email;
mail.parameters.text = "It's done";
mail.execute(bpm_package);

However, I get a 500 error code when I use this :

var mail = actions.create("mail");

mail.parameters.to = initiator.properties.email;
mail.parameters.template =companyhome.childByNamePath("Data Dictionary/Email Templates/Workflow Notification/wf-email.html.ftl");
var templateArgs = new Array();
templateArgs['workflowTitle'] = "workflowTitle";
var templateModel = new Array();
templateModel['args'] = templateArgs;
mail.parameters.template_model = templateModel;  
//mail.parameters.text = "";
mail.parameters.subject = "Adhoc Task " + execution.getVariable('bpm_workflowDescription');
mail.parameters.from = initiator.properties.email;
mail.execute(bpm_package);

The log :

 

2018-09-07 08:18:19,959  ERROR [action.executer.MailActionExecuter] [http-bio-8080-exec-26] Failed to send email to adresse@mail.com : org.springframework.mail.MailSendException: Failed messages: javax.mail.MessagingException: No MimeMessage content; message exceptions (1) are: Failed message 1: javax.mail.MessagingException: No MimeMessage content
 2018-09-07 08:18:19,969  DEBUG [repo.jscript.ScriptLogger] [http-bio-8080-exec-26] org.alfresco.scripts.ScriptException: 08070022 Failed to execute supplied script: 08070021 Failed to send email to:adresse@mail.com
 2018-09-07 08:18:19,970  DEBUG [repo.jscript.ScriptLogger] [http-bio-8080-exec-26] Returning 500 status code

 

When I add this :

logger.log("Template : " + companyhome.childByNamePath("Data Dictionary/Email Templates/Workflow Notification/wf-email.html.ftl"));

logger.log("Template_Data : " + companyhome.childByNamePath("Data Dictionary"));

I get :

Template : null

Template_Data : null

Thanks in advance

11 Replies
Highlighted
Professional

Re: Workflow notification and templates

If you don't already have the JavaScript Console installed you should install it, then copy-and-paste this code into it. Change references to "execution" to hardcoded values for test purposes, then run it and see what happens.

When I run your code in the JS console it successfully find the wf-email.html.ftl template.

Assuming that works for you, the next step might then be to run this locally with the JavaScript Debugger enabled in log4j.properties. When you start Tomcat that will launch a little GUI that you can use to debug the JavaScript getting executed in your process. That might better enable you to see what's going on.

Highlighted
Active Member II

Re: Workflow notification and templates

Hi,

thank you for your answer.

I’m new and I don’t Know how to install the JavaScript console. Is there a tuto please ?

I don’t get What you mean by

« change references to « executions » to harcoded values for test values ». Could you be more specific please ?

Thanks again for your help

Highlighted
Active Member II

Re: Workflow notification and templates

I have tried to install the javascript console but it doesn't work with maven.

GitHub - share-extras/js-console: Administration Console component for Alfresco Share, that enables ... 

I've added the dependancies and overlays in my pom.xml files.

I don't get any errors while building my projet.
But when I navigate to an Administration page such as Users or Group, I don't have the javascript console in the left-hand-side navigation.

Any help please

Highlighted
Professional

Re: Workflow notification and templates

The JavaScript Console works perfectly when installed in your SDK project, so you must have missed a step.

Make sure you've added the repo dependency to "platformModules" as well as the share dependency to "shareModules" in your pom.xml.

Also, comment-in the maven-assembly-plugin so that your project will produce AMPs.

If that still doesn't work, post your pom.xml.

Highlighted
Advanced II

Re: Workflow notification and templates

Dependencies and overlays are only for SDK 2.x.

If you are using the SDK 3.x, then you should use what Jeff Potts‌ said.

Highlighted
Active Member II

Re: Workflow notification and templates

Hi everyone and thank you very much for your answers.

I actually use SDK3.x and I did use dependancies and overlays.

As I'm a newbie I search on how to install javascript console on sdk 3 : Working with Alfresco SDK 3: AMPs | Alfresco 社区 - 中国  --> The javascript console works perfectly.

When I get back to my problem, if I run this code in my JS console :

print(companyhome.childByNamePath("Data Dictionary/Email Templates/Workflow Notification/wf-email_fr.html.ftl"));
print(companyhome.childByNamePath("Data Dictionary/"));

I get on the console output :

null

null

Highlighted
Professional

Re: Workflow notification and templates

Your code copied as-is into my JavaScript console returns:

wf-email_fr.html.ftl (workspace://SpacesStore/8ebe9c46-aa3c-41a0-be01-5a89228778dd)

Data Dictionary (workspace://SpacesStore/06f0b0a3-1359-4005-8959-b932048e3c63)

Are you running as admin?

Can you browse to the Data Dictionary as the ID that is running this code and read the folders and documents that are there?

Highlighted
Active Member II

Re: Workflow notification and templates

Hi Jeff and thank you for your answer.

I am with the admin session so I assume that I run the code as an admin.
Moreover, in my workflow, I use :

<extensionElements>
        <activiti:field name="runAs">
          <activiti:string><![CDATA[admin]]></activiti:string>
        </activiti:field>
        <activiti:field name="script">
          <activiti:string>
                <![CDATA[

I can browse to the data dictionary, read and modify repertories and files in there

When I try to use the code

print(companyhome.childByNamePath("Data Dictionary/Email Templates/Workflow Notification/wf-email_fr.html.ftl"));

in my prod server, I get the same result : "null"

Highlighted
Professional

Re: Workflow notification and templates

Is it possible someone changed the name of any of those folders in that path?

Maybe someone deleted that Freemarker template?

Can you browse to it in the node browser and copy-and-paste the full QName path here for us to compare? Mine is:

/app:company_home/app:dictionary/app:email_templates/cm:workflownotification/cm:invite-email_fr.html.ftl