09-10-2018 07:54 AM
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"));
Template : null
Template_Data : null
Thanks in advance
09-11-2018 02:06 PM
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.
09-11-2018 02:26 PM
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
09-12-2018 07:11 AM
I have tried to install the javascript console but it doesn't work with maven.
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
09-12-2018 01:49 PM
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.
09-12-2018 06:33 PM
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.
09-12-2018 11:40 PM
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
09-17-2018 10:57 PM
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?
09-17-2018 11:20 PM
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"
09-18-2018 12:07 AM
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
Explore our Alfresco products with the links below. Use labels to filter content by product module.