0

I'm implementing a simple mail triggering service to notify about workflow tasks to user. I have used the following code under user task and the mail is getting trigerred as expected, but is there a way to access template from S3 bucket URL/link rather than Data dictionary.

Following is my current code

var mail = actions.create("mail");
mail.parameters.to = "xyx@gmail.com";
mail.parameters.subject="Hello";
mail.parameters.text="blablabla";
mail.parameters.template = companyhome.childByNamePath('Data Dictionary/Email Templates/Workflow Notification/File.html.ftl');
var templateArgs = new Array();
templateArgs['workflowTitle'] = "Page";
templateArgs['workflowDescription'] = "Task Assigned";
templateArgs['workflowId'] = "11111";

var templateModel = new Array();
templateModel['args'] = templateArgs;
mail.parameters.template_model = templateModel;
mail.execute(bpm_package);
Am Novice
  • 325
  • 2
  • 9
  • 21

1 Answers1

1

If you are using the S3 Connector, then all of the objects in your Alfresco repository reside in S3, including freemarker templates.

If you are not using the S3 Connector there is really no easy, out-of-the-box way to pull a template in from S3 or any other source.

You could always write it yourself. You can invoke external REST endpoints from JavaScript controllers of web scripts. You can also write a Java controller that could do it.

Essentially your web script would fetch the template then do your own merge then send the result of the merge as the body of the email.

Not sure how bad you want to store your templates in S3, but that's essentially how you'd do it.

You could also consider writing a scheduled action that would just synchronize objects stored in S3 with nodes in the repo, then your action would work unchanged.

Jeff Potts
  • 10,468
  • 17
  • 40