0

I created mail task configuration

<serviceTask id="mailtask_name" name="Name" flowable:delegateExpression="${STCustomMail}" flowable:type="mail" >
  <extensionElements>
    <flowable:field name="to">
      <flowable:string><![CDATA[mail@mail.com]]></flowable:string>
    </flowable:field>
    <flowable:field name="subject">
      <flowable:string><![CDATA[Subject]]></flowable:string>
    </flowable:field>
    <flowable:field name="text">
      <flowable:string><![CDATA[Text]]></flowable:string>
    </flowable:field>
  </extensionElements>
</serviceTask>

and class:

@Log
@Service
public class STCustomMail implements JavaDelegate {

   private Expression subject;
   private Expression to;
   private Expression text;

   public void execute(DelegateExecution execution) {
      log.info("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
      String subjectText = "New subject";
      execution.setVariable(subject.getValue(execution).toString(), subjectText);
      execution.setVariable(to.getValue(execution).toString(), "newmail@newmail.com");
      execution.setVariable(text.getValue(execution).toString(), "newtext");
   }
}

Unfortunatelly, my STCustomMail class is not working. I can't modify any mail data.

What is wrong?

Maybe there is another solution how to configure/create dynamically(?) mail data location?

cwiq
  • 105
  • 2
  • 15

1 Answers1

1

flowable:delegateExpression and flowable:type cannot be mixed together.

By default when the flowable:type is mail then Flowable will use the MailActivityBehavior to perform the send of the email. This means that your JavaDelegate will never get invoked.

If you want to change the mail activity behavior they you would need to provide your own implementation for it. In order to do that you would need to provide your own ActivityBehaviorFactory (you can extend the DefaultActivityBehaviorFactory) and override the following methods:

  • MailActivityBehavior createMailActivityBehavior(ServiceTask serviceTask)
  • MailActivityBehavior createMailActivityBehavior(SendTask sendTask)
Filip
  • 19,269
  • 7
  • 51
  • 60