// Crea el correo y le añade las propiedades como el To, Subject, ect
var mail = actions.create("mail");
mail.parameters.to = person.properties.email
mail.parameters.subject = "Nota de gastos \"" + document.properties.name + "\" subida en Alfresco";
mail.parameters.from = "gestionweb@micorreo.com";
mail.parameters.template = root.childByNamePath("Company Home/Data Dictionary/Email Templates/Notify Email Templates/notify_user_email.ftl");
// ejecuta el envio del correo
mail.execute(document);
// Cambia valor estado
document.properties["Notas:NotasGastosEstado"] = "Creada";
document.save();
Por favor corrija los errores siguientes y pulse Aceptar.
•Failed to create content due to error: 07200169 Failed to execute script 'workspace://SpacesStore/fa285d58-6a91-4b4d-af11-2de5e786acac': 07200168 ReferenceError: "root" is not defined. (workspace://SpacesStore/fa285d58-6a91-4b4d-af11-2de5e786acac#6)
Buenas de nuevo ATC.
Uhm, a simple vista no se me ocurre nada pero te voy a dar un consejo: Para "depurar" el código JS, afresco tiene una consola interna.. algo así como un eclipse super-básico, pero sirve.
Para activar el debugger éste debes meterte en http://localhost:8080/alfresco/service/api/javascript/debugger Ponerlo en enabled y a continuación lanzar el script. Verás como en la ventanita se te pone el script que estás haciendo, pues bien, puedes poner puntos de ruptura, mirar qué contienen las variables que quieras ver, etc, etc..
Esto puede servirte para ver si ha algun valor que toma mal o hay algo incorrecto para que te de ese error.
Desde luego a mi me sirvió de mucho cuando he tenido que hacer algun desarrollo en JS
Espero que te sirva.
Un saludooo!
mail.parameters.template = companyhome.childByNamePath("Data Dictionary/Email Templates/Notify Email Templates/notify_user_email.ftl");
Hola, el objeto "root" no se encuentra definido en el API; mejor usa el objeto "companyhome":
mail.parameters.template = companyhome.childByNamePath("Data Dictionary/Email Templates/Notify Email Templates/notify_user_email.ftl");
Un saludo.
Buenas de nuevo ATC.
Uhm, a simple vista no se me ocurre nada pero te voy a dar un consejo: Para "depurar" el código JS, afresco tiene una consola interna.. algo así como un eclipse super-básico, pero sirve.
Para activar el debugger éste debes meterte en http://localhost:8080/alfresco/service/api/javascript/debugger Ponerlo en enabled y a continuación lanzar el script. Verás como en la ventanita se te pone el script que estás haciendo, pues bien, puedes poner puntos de ruptura, mirar qué contienen las variables que quieras ver, etc, etc..
Esto puede servirte para ver si ha algun valor que toma mal o hay algo incorrecto para que te de ese error.
Desde luego a mi me sirvió de mucho cuando he tenido que hacer algun desarrollo en JS
Espero que te sirva.
Un saludooo!
Pon el error por aquí a ver si podemos dar con lo que es…
13:09:59,012 ERROR [org.alfresco.web.ui.common.Utils] Failed to create content due to error: 07230372 Failed to execute script 'workspace://SpacesStore/9a601446-770d-42d6-ab28-6cc713a81e59': 07230371 Failed to send email to:micorreo@micorreo.com
org.alfresco.scripts.ScriptException: 07230372 Failed to execute script 'workspace://SpacesStore/9a601446-770d-42d6-ab28-6cc713a81e59': 07230371 Failed to send email to:micorreo@micorreo.com
at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:233)
at org.alfresco.repo.processor.ScriptServiceImpl.executeScript(ScriptServiceImpl.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
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:43)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:135)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy229.executeScript(Unknown Source)
at org.alfresco.repo.action.executer.ScriptActionExecuter.executeImpl(ScriptActionExecuter.java:163)
at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:133)
at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:726)
at org.alfresco.repo.action.executer.CompositeActionExecuter.executeImpl(CompositeActionExecuter.java:66)
at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:133)
at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:726)
at org.alfresco.repo.action.ActionServiceImpl.executeActionImpl(ActionServiceImpl.java:658)
at org.alfresco.repo.action.ActionServiceImpl.executeAction(ActionServiceImpl.java:526)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
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:43)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:135)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy36.executeAction(Unknown Source)
at org.alfresco.repo.rule.RuleServiceImpl.executeRule(RuleServiceImpl.java:1118)
at org.alfresco.repo.rule.RuleServiceImpl.executePendingRule(RuleServiceImpl.java:1086)
at org.alfresco.repo.rule.RuleServiceImpl.executePendingRulesImpl(RuleServiceImpl.java:1057)
at org.alfresco.repo.rule.RuleServiceImpl.executePendingRules(RuleServiceImpl.java:1030)
at org.alfresco.repo.rule.RuleTransactionListener.beforeCommit(RuleTransactionListener.java:57)
at org.alfresco.repo.transaction.AlfrescoTransactionSupport$TransactionSynchronizationImpl.doBeforeCommit(AlfrescoTransactionSupport.java:738)
at org.alfresco.repo.transaction.AlfrescoTransactionSupport$TransactionSynchronizationImpl.doBeforeCommit(AlfrescoTransactionSupport.java:718)
at org.alfresco.repo.transaction.AlfrescoTransactionSupport$TransactionSynchronizationImpl.beforeCommit(AlfrescoTransactionSupport.java:674)
at org.springframework.transaction.support.TransactionSynchronizationUtils.triggerBeforeCommit(TransactionSynchronizationUtils.java:95)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.triggerBeforeCommit(AbstractPlatformTransactionManager.java:927)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:737)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:394)
at org.alfresco.util.transaction.SpringAwareUserTransaction.commit(SpringAwareUserTransaction.java:472)
at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:343)
at org.alfresco.web.bean.dialog.BaseDialogBean.finish(BaseDialogBean.java:124)
at org.alfresco.web.bean.dialog.DialogManager.finish(DialogManager.java:528)
at sun.reflect.GeneratedMethodAccessor982.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:132)
at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:61)
at javax.faces.component.UICommand.broadcast(UICommand.java:109)
at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:97)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:171)
at org.apache.myfaces.lifecycle.InvokeApplicationExecutor.execute(InvokeApplicationExecutor.java:32)
at org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:95)
at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:70)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:139)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.alfresco.web.app.servlet.AuthenticationFilter.doFilter(AuthenticationFilter.java:104)
at sun.reflect.GeneratedMethodAccessor455.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:116)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy206.doFilter(Unknown Source)
at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:82)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.alfresco.repo.web.filter.beans.NullFilter.doFilter(NullFilter.java:68)
at sun.reflect.GeneratedMethodAccessor455.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.alfresco.repo.management.subsystems.ChainingSubsystemProxyFactory$1.invoke(ChainingSubsystemProxyFactory.java:116)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy206.doFilter(Unknown Source)
at org.alfresco.repo.web.filter.beans.BeanProxyFilter.doFilter(BeanProxyFilter.java:82)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:636)
Caused by: org.alfresco.error.AlfrescoRuntimeException: 07230371 Failed to send email to:micorreo@micorreo.com
at org.alfresco.repo.action.executer.MailActionExecuter.executeImpl(MailActionExecuter.java:466)
at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:133)
at sun.reflect.GeneratedMethodAccessor1132.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.alfresco.repo.management.subsystems.SubsystemProxyFactory$1.invoke(SubsystemProxyFactory.java:65)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy228.execute(Unknown Source)
at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:726)
at org.alfresco.repo.action.ActionServiceImpl.executeActionImpl(ActionServiceImpl.java:658)
at org.alfresco.repo.action.ActionServiceImpl.executeAction(ActionServiceImpl.java:526)
at org.alfresco.repo.action.ActionServiceImpl.executeAction(ActionServiceImpl.java:512)
at org.alfresco.repo.action.ActionServiceImpl.executeAction(ActionServiceImpl.java:735)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
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:43)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:135)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy36.executeAction(Unknown Source)
at org.alfresco.repo.jscript.ScriptAction.executeImpl(ScriptAction.java:159)
at org.alfresco.repo.jscript.ScriptAction.execute(ScriptAction.java:148)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:161)
at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:247)
at org.mozilla.javascript.optimizer.OptRuntime.call1(OptRuntime.java:66)
at org.mozilla.javascript.gen.c11._c0(workspace://SpacesStore/9a601446-770d-42d6-ab28-6cc713a81e59:10)
at org.mozilla.javascript.gen.c11.call(workspace://SpacesStore/9a601446-770d-42d6-ab28-6cc713a81e59)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:398)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3065)
at org.mozilla.javascript.gen.c11.call(workspace://SpacesStore/9a601446-770d-42d6-ab28-6cc713a81e59)
at org.mozilla.javascript.gen.c11.exec(workspace://SpacesStore/9a601446-770d-42d6-ab28-6cc713a81e59)
at org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:453)
at org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:229)
… 106 more
Caused by: org.springframework.mail.MailPreparationException: Could not prepare mail; nested exception is java.lang.IllegalArgumentException: Text must not be null
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:368)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:345)
at org.alfresco.repo.action.executer.MailActionExecuter.executeImpl(MailActionExecuter.java:439)
… 153 more
Caused by: java.lang.IllegalArgumentException: Text must not be null
at org.springframework.util.Assert.notNull(Assert.java:112)
at org.springframework.mail.javamail.MimeMessageHelper.setText(MimeMessageHelper.java:768)
at org.springframework.mail.javamail.MimeMessageHelper.setText(MimeMessageHelper.java:753)
at org.alfresco.repo.action.executer.MailActionExecuter$1.prepare(MailActionExecuter.java:405)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:353)
… 155 more
mail.parameters.template = companyhome.childByNamePath('Company Home/Data Dictionary/Email Templates/Notify Email Templates/Mi Prueba.ftl');
mail.parameters.template = companyhome.childByNamePath('Data Dictionary/Email Templates/Notify Email Templates/Mi Prueba.ftl');
mail.parameters.template = companyhome.childByNamePath('Company Home/Data Dictionary/Email Templates/Notify Email Templates/Mi Prueba.ftl');
No lo he probado empíricamente, pero creo que al rescatar del objeto companyhome ya te introduce dentro de este espacio de trabajo, ¿y si quitas ese espacio?, es decir:
Ponerlo así:mail.parameters.template = companyhome.childByNamePath('Data Dictionary/Email Templates/Notify Email Templates/Mi Prueba.ftl');
(Quitando "Company Home/")
En lugar de:mail.parameters.template = companyhome.childByNamePath('Company Home/Data Dictionary/Email Templates/Notify Email Templates/Mi Prueba.ftl');
Un saludo.
Content from pre 2016 and from language groups that have been closed.
Content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.