AnsweredAssumed Answered

Error : ReferenceError: 'companyhome' is not defined.

Question asked by nitinkcv on Nov 3, 2009
Latest reply on May 24, 2011 by sans
Hi,

I'm actually trying to trigger a mail using the AlfrescoJavascript.

Part of my code in the process definition file is:


<transition name="moreInfoNeeded" to="moreInfoNeeded" >
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
                <variable name="bpm_package" access="read" />
                <variable name="initiator" access="read" />
                <variable name="bpm_workflowDescription" access="read" />
                <expression>
                     var mail = actions.create("mail");
                     var prsn = initiator;
                     try {
                        var emailAddress = prsn.properties.email;
                        mail.parameters.to = emailAddress;
                        mail.parameters.subject = "Content authoring task submitted with additional information";
                        mail.parameters.from = person.properties.email;
                        mail.parameters.template = companyhome.childByNamePath("Data Dictionary/Email Templates/notify_user_email_taskurl.ftl");                        
                        mail.parameters.text = "Default text goes here";
                        mail.execute(bpm_package);
                        logger.log("send mail to "+ prsn.properties.userName);
                     } catch (error) {
                        logger.log("Failed sending mail to "+ prsn.properties.userName + "  " + error);
                     }
               </expression>   
             </script>
         </action>
      </transition>

My ftl file is the below:


Hi,

A new workflow task has been created.
Please got to http://${url.context}/alfresco/command/ui/managetask?id=${pooled.id}&type=${pooled.qnameType}&container=plain to view the workflow task.

Regards

Admin


However when i check my log file i get the following error:

DEBUG [org.alfresco.repo.jscript.ScriptLogger] Failed sending mail to admin ReferenceError: "companyhome" is not defined.

I have made use of companyhome in my process definition file to get the hold of an image and it worked.

Has anyone come across this before?

Thanks.

Outcomes