I have webscript written in Javascript for send emails. It works pretty well, but I would like to send those emails in background, so that action can not slow further code execution. How can I do that?
Thanks in advance!
Best,
D
Addtional code:
I created sendmail.lib.js which is included in needed js files with following signature:
function sendmail(to, subject, nodeRef, templatePath, templateArgs, textIfTemplateNotFound )
This function ends with the line:
mail.execute(search.findNode(nodeRef));
This is the way I need to send e-mails and on very specific events not related to “out-of-the-box” Alfresco events.
Since you’re working with an Action, then the answer is very simple. What you want to do is Asynchronous Execution of your Action. Alfresco will then add your action to the async action queue, and will run it as soon as one of the async threads is available.
Instead of
You instead to
And that’s it! For more information on what you can do with actions in JavaScript, either have a look at the documentation on the wiki, or just read the ScriptAction source code