cancel
Showing results for 
Search instead for 
Did you mean: 

Using wf-email.htmll template from JS

dranakan
Champ on-the-rise
Champ on-the-rise
Hello,

I want to use the template wf-email.html.ftl but I don't know how to specify the $shareUrl (and other var). How can I define $shareUrl, $productName, …

Code to send the mail with template

  var mail = actions.create("mail");
  mail.parameters.to = "me@custom.ch";
  mail.parameters.subject = "Test template";
var docTemplate = companyhome.childByNamePath("Data Dictionary/Email Templates/Workflow Notification/wf-email.html.ftl");
node = search.findNode("workspace://SpacesStore/de567518-bf00-4a08-9031-434bf8c3d766");
var args=new Array();
args['workflowTitle']="blabla";
mail.parameters.text=node.processTemplate(docTemplate,args);
mail.execute(node);

wf-email.html.ftl

<html>
   <head>
      <style type="text/css"><!–
      body
      {
         font-family: Arial, sans-serif;
         font-size: 14px;
         color: #4c4c4c;
      }
     
      a, a:visited
      {
         color: #0072cf;
      }
      –></style>
   </head>
  
   <body bgcolor="#dddddd">
      <table width="100%" cellpadding="20" cellspacing="0" border="0" bgcolor="#dddddd">
         <tr>
            <td width="100%" align="center">
               <table width="70%" cellpadding="0" cellspacing="0" bgcolor="white" style="background-color: white; border: 1px solid #aaaaaa;">
                  <tr>
                     <td width="100%">
                        <table width="100%" cellpadding="0" cellspacing="0" border="0">
                           <tr>
                              <td style="padding: 10px 30px 0px;">
                                 <table width="100%" cellpadding="0" cellspacing="0" border="0">
                                    <tr>
                                       <td>
                                          <table cellpadding="0" cellspacing="0" border="0">
                                             <tr>
                                                <td>
                                                   <img src="${shareUrl}/res/components/images/task-64.png" alt="" width="64" height="64" border="0" style="padding-right: 20px;" />
                                                </td>
                                                <td>
                                                   <div style="font-size: 22px; padding-bottom: 4px;">
                                                      <#if args.workflowPooled == true>
                                                         New Pooled Task
                                                      <#else>
                                                         You have been assigned a task
                                                      </#if>
                                                   </div>
                                                   <div style="font-size: 13px;">
                                                      ${date?datetime?string.full}
                                                   </div>
                                                </td>
                                             </tr>
                                          </table>
                                          <div style="font-size: 14px; margin: 12px 0px 24px 0px; padding-top: 10px; border-top: 1px solid #aaaaaa;">
                                             <p>Hi,</p>

                                             <p>
                                                <#if args.workflowPooled == true>
                                                   The following pooled task is available to be claimed:
                                                <#else>
                                                   You have been assigned the following task:
                                                </#if>
                                             </p>
                                            
                                             <p><b>"${args.workflowTitle}"</b></p>
                                            
                                             <#if (args.workflowDescription)??>                                            
                                                <p>${args.workflowDescription}</p>                                            
                                             </#if>
                                            
                                             <p>
                                                <#if (args.workflowDueDate)??>Due:  <b>${args.workflowDueDate?date?string.full}</b><br></#if>
                                                <#if (args.workflowPriority)??>
                                                   Priority:  
                                                   <b>
                                                   <#if args.workflowPriority == 3>
                                                      Low
                                                   <#elseif args.workflowPriority == 2>
                                                      Medium
                                                   <#else>
                                                      High
                                                   </#if>
                                                   </b>
                                                </#if>
                                             </p>
                                            
                                             <#if (args.workflowDocuments)??>
                                                <table cellpadding="0" callspacing="0" border="0" bgcolor="#eeeeee" style="padding:10px; border: 1px solid #aaaaaa;">
                                                   <#list args.workflowDocuments as doc>
                                                      <tr>
                                                         <td>
                                                            <table cellpadding="0" cellspacing="0" border="0">
                                                               <tr>
                                                                  <td valign="top">
                                                                     <img src="${shareUrl}/res/components/images/generic-file.png" alt="" width="64" height="64" border="0" style="padding-right: 10px;" />
                                                                  </td>
                                                                  <td>
                                                                     <table cellpadding="2" cellspacing="0" border="0">
                                                                        <tr>
                                                                           <td><b>${doc.name}</b></td>
                                                                        </tr>
                                                                        <tr>
                                                                           <td>Click on this link to download the document:</td>
                                                                        </tr>
                                                                        <tr>
                                                                           <td>
                                                                              <a href="${shareUrl}/proxy/alfresco/api/node/content/workspace/SpacesStore/${doc.id}/${doc.name}?a=true">
                                                                              ${shareUrl}/proxy/alfresco/api/node/content/workspace/SpacesStore/${doc.id}/${doc.name}?a=true</a>
                                                                           </td>
                                                                        </tr>
                                                                     </table>
                                                                  </td>
                                                               </tr>
                                                            </table>
                                                         </td>
                                                      </tr>
                                                      <#if doc_has_next>
                                                         <tr><td><div style="border-top: 1px solid #aaaaaa; margin:12px;"></div></td></tr>
                                                      </#if>
                                                   </#list>
                                                </table>
                                             </#if>
                                            
                                             <#if args.workflowPooled == true>
                                                <p>Click this link to view the task:</p>
                                                <p><a href="${shareUrl}/page/task-details?taskId=${args.workflowId}">${shareUrl}/page/task-details?taskId=${args.workflowId}</a>
                                             <#else>
                                                <p>Click this link to edit the task:</p>
                                                <p><a href="${shareUrl}/page/task-edit?taskId=${args.workflowId}">${shareUrl}/page/task-edit?taskId=${args.workflowId}</a>
                                             </#if>
                                            
                                             <p>Sincerely,<br />
                                             Alfresco ${productName!""}</p>
                                          </div>
                                       </td>
                                    </tr>
                                 </table>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <div style="border-top: 1px solid #aaaaaa;"> </div>
                              </td>
                           </tr>
                           <tr>
                              <td style="padding: 0px 30px; font-size: 13px;">
                                 To find out more about Alfresco ${productName!""} visit <a href="http://www.alfresco.com">http://www.alfresco.com</a>
                              </td>
                           </tr>
                           <tr>
                              <td>
                                 <div style="border-bottom: 1px solid #aaaaaa;"> </div>
                              </td>
                           </tr>
                           <tr>
                              <td style="padding: 10px 30px;">
                                 <img src="${shareUrl}/themes/default/images/app-logo.png" alt="" width="117" height="48" border="0" />
                              </td>
                           </tr>
                        </table>
                     </td>
                  </tr>
               </table>
            </td>
         </tr>
      </table>
   </body>
</html>

Error sending the mail :

500 Description:   An error inside the HTTP server which prevented it from fulfilling the request.

Message:   11150065 Wrapped Exception (with status template): 11152208 Failed to execute script 'classpath*:alfresco/templates/webscripts/org/alfresco/module/custom/searchWorkflow/searchWorkflow.get.js': 11152207 Error during processing of the template 'Expression shareUrl is undefined on line 34, column 64 in string://fixed.'. Please contact your system administrator.
   
Exception:   freemarker.core.InvalidReferenceException - Expression shareUrl is undefined on line 34, column 64 in string://fixed.
   
   freemarker.core.TemplateObject.assertNonNull(TemplateObject.java:125)
   freemarker.core.Expression.getStringValue(Expression.java:118)
   freemarker.core.Expression.getStringValue(Expression.java:93)
   freemarker.core.DollarVariable.accept(DollarVariable.java:76)
   freemarker.core.Environment.visit(Environment.java:221)
   freemarker.core.MixedContent.accept(MixedContent.java:92)
   freemarker.core.Environment.visit(Environment.java:221)
   freemarker.core.Environment.process(Environment.java:199)
   freemarker.template.Template.process(Template.java:237)
   org.alfresco.repo.template.FreeMarkerProcessor.processString(FreeMarkerProcessor.java:260)
   org.alfresco.repo.processor.TemplateServiceImpl.processTemplateString(TemplateServiceImpl.java:208)
   org.alfresco.repo.processor.TemplateServiceImpl.processTemplateString(TemplateServiceImpl.java:227)
   sun.reflect.GeneratedMethodAccessor1511.invoke(Unknown Source)
   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   java.lang.reflect.Method.invoke(Method.java:597)
   org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
   org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
   org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
   org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:34)
   org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:44)
   org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:146)
   org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
   org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
   org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
   $Proxy107.processTemplateString(Unknown Source)
   org.alfresco.repo.jscript.ScriptNode.processTemplate(ScriptNode.java:2623)
   org.alfresco.repo.jscript.ScriptNode.processTemplate(ScriptNode.java:2537)
   sun.reflect.GeneratedMethodAccessor1509.invoke(Unknown Source)
   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   java.lang.reflect.Method.invoke(Method.java:597)
   org.mozilla.javascript.MemberBox.invoke(MemberBox.java:155)
   org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:243)
   org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:76)
   org.mozilla.javascript.gen.c75._c0(file:/opt/alfresco-4.0.b/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/module/custom/searchWorkflow/searchWorkflow.get.js:51)
   org.mozilla.javascript.gen.c75.call(file:/opt/alfresco-4.0.b/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/module/custom/searchWorkflow/searchWorkflow.get.js)
   org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
   org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
   org.mozilla.javascript.gen.c75.call(file:/opt/alfresco-4.0.b/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/module/custom/searchWorkflow/searchWorkflow.get.js)
   org.mozilla.javascript.gen.c75.exec(file:/opt/alfresco-4.0.b/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/module/custom/searchWorkflow/searchWorkflow.get.js)
   org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:483)
   org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:191)
   org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:282)
   org.alfresco.repo.web.scripts.RepositoryScriptProcessor.executeScript(RepositoryScriptProcessor.java:102)
   org.springframework.extensions.webscripts.AbstractWebScript.executeScript(AbstractWebScript.java:1128)
   org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:86)
   org.alfresco.repo.web.scripts.RepositoryContainer$2.execute(RepositoryContainer.java:400)
   org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:388)
   org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:462)
   org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:500)
   org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:316)
   org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:372)
   org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)
   org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:118)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:58)
   org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
   org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:465)
   org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
   org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
   org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
   org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
   java.lang.Thread.run(Thread.java:619)
   
Exception:   org.alfresco.service.cmr.repository.TemplateException - 11152207 Error during processing of the template 'Expression shareUrl is undefined on line 34, column 64 in string://fixed.'. Please contact your system administrator.
   
   org.alfresco.repo.template.FreeMarkerProcessor.processString(FreeMarkerProcessor.java:270)
   
Exception:   org.alfresco.scripts.ScriptException - 11152208 Failed to execute script 'classpath*:alfresco/templates/webscripts/org/alfresco/module/custom/searchWorkflow/searchWorkflow.get.js': 11152207 Error during processing of the template 'Expression shareUrl is undefined on line 34, column 64 in string://fixed.'. Please contact your system administrator.
   
   org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:195)
   
Exception:   org.springframework.extensions.webscripts.WebScriptException - 11150065 Wrapped Exception (with status template): 11152208 Failed to execute script 'classpath*:alfresco/templates/webscripts/org/alfresco/module/custom/searchWorkflow/searchWorkflow.get.js': 11152207 Error during processing of the template 'Expression shareUrl is undefined on line 34, column 64 in string://fixed.'. Please contact your system administrator.
   
   org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:905)

Related subject

I18 with template : https://forums.alfresco.com/en/viewtopic.php?f=36&t=42051
21 REPLIES 21

lukasz_turakiew
Champ in-the-making
Champ in-the-making
Hi,

Please try the following code:

var mail = actions.create("mail");
// This needs to be changed
mail.parameters.to = "receiver_email@some.domain";
mail.parameters.subject = "Test subject";
mail.parameters.template = companyhome.childByNamePath("Data Dictionary/Email Templates/Workflow Notification/wf-email.html.ftl");

var templateArgs = new Array();
templateArgs['workflowTitle'] = "workflowTitle";
templateArgs['workflowPooled'] = true;
templateArgs['workflowDescription'] = "workflowDesc";
templateArgs['workflowId'] = "workflowId";

var templateModel = new Array();
templateModel['args'] = templateArgs;

mail.parameters.template_model = templateModel;

// The node identifier needs to be changed
mail.execute(search.findNode("workspace://SpacesStore/9e15aaac-b30b-4266-984f-21fe273a6113"));
Although it is possible to use wf-email.html.ftl in such a way, it is not necessarily the way how it should be used.

Best regards,
Lukasz Turakiewicz

dranakan
Champ on-the-rise
Champ on-the-rise
Thank you Lukasz 🙂 It's working 🙂

Do you use the i18n ? (how can I select the wf-email.html_fr.ftl depending the browser langage ?)

lukasz_turakiew
Champ in-the-making
Champ in-the-making
You could read 'Accept-Language' header:

var acceptLanguage = headers["accept-language"];
and depending on its value choose an appropriate template - however it seems that it is not the smartest solution for this issue Smiley Happy

Regards,
Lukasz Turakiewicz

dranakan
Champ on-the-rise
Champ on-the-rise
You could read 'Accept-Language' header:

var acceptLanguage = headers["accept-language"];
and depending on its value choose an appropriate template - however it seems that it is not the smartest solution for this issue Smiley Happy
Thank you Lukasz.

I can get the value of my browser if the code is inside a Webscript (Javascript code), but it's not working inside workflow (Javascript code) : headers is not defined. Do I add something ?

Workflow (activiti, Alfresco 4.0b)


<userTask id="modifyReview1" name="Validation 1"
                        activiti:assignee="${sgfwf_assignee1.properties.userName}"
                        activiti:formKey="sgfwf:modifyReviewTaskReviewByBoss3">
                        <extensionElements>
                                <activiti:taskListener event="create"
                                        class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                                        <activiti:field name="script">
                                                <activiti:string>
                                                       var acceptLanguage = headers["accept-language"];
                                                        logger.debug("Language : "+acceptLanguage);


Error log

org.activiti.engine.ActivitiException: Exception while invoking TaskListener: Exception while invoking TaskListener: 11200026 Failed to execute supplied script: 11200025 ReferenceError: "headers" is not defined. (AlfrescoJS#4)
        at org.activiti.engine.impl.persistence.entity.TaskEntity.fireEvent(TaskEntity.java:516)
        at org.activiti.engine.impl.bpmn.behavior.UserTaskActivityBehavior.execute(UserTaskActivityBehavior.java:70)
        at org.activiti.engine.impl.pvm.runtime.AtomicOperationActivityExecute.execute(AtomicOperationActivityExecute.java:40)
        at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
        at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
        at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerStart.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerStart.java:48)
        at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:52)
        at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
        at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
        at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:45)
        at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
        at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
        at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionCreateScope.execute(AtomicOperationTransitionCreateScope.java:44)
        at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
        at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
        at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerTake.execute(AtomicOperationTransitionNotifyListenerTake.java:61)
        at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
        at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
        at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionDestroyScope.execute(AtomicOperationTransitionDestroyScope.java:111)
        at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
        at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
        at org.activiti.engine.impl.pvm.runtime.AtomicOperationTransitionNotifyListenerEnd.eventNotificationsCompleted(AtomicOperationTransitionNotifyListenerEnd.java:36)
        at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:52)
        at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)
        at org.activiti.engine.impl.persistence.entity.ExecutionEntity.performOperation(ExecutionEntity.java:481)
        at org.activiti.engine.impl.pvm.runtime.AbstractEventAtomicOperation.execute(AbstractEventAtomicOperation.java:45)
        at org.activiti.engine.impl.interceptor.CommandContext.performOperation(CommandContext.java:76)

    at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:243)
        at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:86)
        at org.mozilla.javascript.gen.c9._c1(file:/opt/alfresco-4.0.b/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/repository/forms/form.post.json.js:57)
        at org.mozilla.javascript.gen.c9.call(file:/opt/alfresco-4.0.b/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/repository/forms/form.post.json.js)
        at org.mozilla.javascript.optimizer.OptRuntime.callName0(OptRuntime.java:108)
        at org.mozilla.javascript.gen.c9._c0(file:/opt/alfresco-4.0.b/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/repository/forms/form.post.json.js:90)
        at org.mozilla.javascript.gen.c9.call(file:/opt/alfresco-4.0.b/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/repository/forms/form.post.json.js)
        at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:393)
        at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:2834)
        at org.mozilla.javascript.gen.c9.call(file:/opt/alfresco-4.0.b/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/repository/forms/form.post.json.js)
        at org.mozilla.javascript.gen.c9.exec(file:/opt/alfresco-4.0.b/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/templates/webscripts/org/alfresco/repository/forms/form.post.json.js)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:483)
        at org.alfresco.repo.jscript.RhinoScrip

Caused by: org.activiti.engine.ActivitiException: Exception while invoking TaskListener: 11200026 Failed to execute supplied script: 11200025 ReferenceError: "headers" is not defined. (AlfrescoJS#4)
        at org.activiti.engine.impl.bpmn.helper.ClassDelegate.notify(ClassDelegate.java:94)
        at org.activiti.engine.impl.delegate.TaskListenerInvocation.invoke(TaskListenerInvocation.java:34)
        at org.activiti.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:37)
        at org.activiti.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:25)
        at org.activiti.engine.impl.persistence.entity.TaskEntity.fireEvent(TaskEntity.java:512)
        … 146 more
Caused by: org.alfresco.scripts.ScriptException: 11200026 Failed to execute supplied script: 11200025 ReferenceError: "headers" is not defined. (AlfrescoJS#4)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.executeString(RhinoScriptProcessor.java:271)
        at org.alfresco.repo.processor.ScriptServiceImpl.executeScriptString(ScriptServiceImpl.java:322)
        at org.alfresco.repo.processor.ScriptServiceImpl.executeScriptString(ScriptServiceImpl.java:300)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
        at org.alfresco.repo.security.permissions.impl.AlwaysProceedMethodInterceptor.invoke(AlwaysProceedMethodInterceptor.java:34)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:44)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:146)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
        at $Proxy249.executeScriptString(Unknown Source)
        at org.alfresco.repo.workflow.activiti.script.ActivitiScriptBase.executeScript(ActivitiScriptBase.java:104)
        at org.alfresco.repo.workflow.activiti.script.ActivitiScriptBase.executeScript(ActivitiScriptBase.java:62)
        at org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener.notify(ScriptTaskListener.java:76)
        at org.activiti.engine.impl.delegate.TaskListenerInvocation.invoke(TaskListenerInvocation.java:34)
        at org.activiti.engine.impl.delegate.DelegateInvocation.proceed(DelegateInvocation.java:37)
        at org.activiti.engine.impl.delegate.DefaultDelegateInterceptor.handleInvocation(DefaultDelegateInterceptor.java:25)
        at org.activiti.engine.impl.bpmn.helper.ClassDelegate.notify(ClassDelegate.java:90)
        … 150 more
Caused by: org.alfresco.error.AlfrescoRuntimeException: 11200025 ReferenceError: "headers" is not defined. (AlfrescoJS#4)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:499)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.executeString(RhinoScriptProcessor.java:267)
        … 176 more
Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "headers" is not defined. (AlfrescoJS#4)
        at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3350)
        at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3340)
        at org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3413)
        at org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1612)
        at org.mozilla.javascript.gen.c10._c0(AlfrescoJS:4)
        at org.mozilla.javascript.gen.c10.call(AlfrescoJS)
        at org.mozilla.javascript.gen.c10.exec(AlfrescoJS)
        at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:483)
        … 177 more
2011-12-20 08:48:34,442  DEBUG [repo.jscript.ScriptLogger] [http-8080-1] org.alfresco.service.cmr.workflow.WorkflowException: 11200027 Impossible de démarrer le workflow activiti$ReviewByBoss3:75:47203.
2011-12-20 08:48:34,442  DEBUG [repo.jscript.ScriptLogger] [http-8080-1] Returning 500 status code

lukasz_turakiew
Champ in-the-making
Champ in-the-making
Hi,

Please try if the following code will work(I have currently no possibility to check it).

person.properties["{http://www.alfresco.org/model/system/1.0}locale"]

Regards,
Lukasz Turakiewicz

dranakan
Champ on-the-rise
Champ on-the-rise
It's always returning "en_US". I change Firefox in fr or de, the language change in the forms, but the code always returning "en_US".
I am looking for a code based on the user interface… I am searching…

amandaluniz_z
Champ on-the-rise
Champ on-the-rise
You will need to pass the locale to the workflow as a parameter…

It runs in another thread, so you will need to add it to the workflow and read it when trying to send the email to set the current thread's locale I18NUtil.setLocale(locale) from java (I think you cannot do it from javascript. Or… add it to the end of the template name (not best option if the template doesn't exist…)

dranakan
Champ on-the-rise
Champ on-the-rise
Thank you amandaluniz_z.

You will need to pass the locale to the workflow as a parameter…
They could be differents users having different languages during the Workflows.
I don't know if the language of the browser set the i18NUtil… I have to test it.

var acceptLanguage = headers["accept-language"];
Why this is not working during the workflow ?

lukasz_turakiew
Champ in-the-making
Champ in-the-making
Hi,

You will need to pass the locale to the workflow as a parameter…

Wouldn't be easier(and faster to implement) to read locale from the user(for example: bpm_assignee.properties["sys:locale"]) to which
email has to be sent rather than passing it as a workflow parameter?

Regards,
Lukasz Turakiewicz