As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
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);
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
logger.log("Template : " + companyhome.childByNamePath("Data Dictionary/Email Templates/Workflow Notification/wf-email.html.ftl"));logger.log("Template_Data : " + companyhome.childByNamePath("Data Dictionary"));
logger.log("Template : " + companyhome.childByNamePath("Data Dictionary/Email Templates/Workflow Notification/wf-email.html.ftl"));
logger.log("Template_Data : " + companyhome.childByNamePath("Data Dictionary"));
Template : nullTemplate_Data : null
Template : null
Template_Data : null
Thanks in advance
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.
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
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 the execution of arb…
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
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.
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.
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 :
nullnull
null
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)
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?
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"
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
Thanks for your answer.From now, I am the only one who use the application.
In the node browser when I seach with the noderef of the invite-email_fr.html.ftl file, I get the primary path /app:company_home/app:dictionary/app:email_templates/cm:workflownotification/cm:invite-email_fr.html.ftl
Well, that is strange. If you are logged in to Share as admin and you can browse and search for that template, you should be able to use the JavaScript Console to run that print statement and it should work.