I want to create a workflow which will trigger an email when a new employee_profile component is dragged & dropped into the parsys in profile page. I have created a workflow which is not getting triggered on drag & drop, I have to manually start it from sidekick tab. In launcher I have given path till.
path : /content/demo/en/profile/jcr:content
eventType : modified
contentType : cq:pageContent
I somehow created a workflow to send an email to my gmail account using Java class CustomStep which is containing the code:
@Component
@Service
@Properties({
@Property(name = Constants.SERVICE_DESCRIPTION, value = "Test Email workflow process implementation."),
@Property(name = Constants.SERVICE_VENDOR, value = "Adobe"),
@Property(name = "process.label", value = "Test Email Workflow Process") })
public class CustomStep implements com.day.cq.workflow.exec.WorkflowProcess {
/** Default log. */
protected final Logger log = LoggerFactory.getLogger(this.getClass());
//Inject a MessageGatewayService
@Reference
private MessageGatewayService messageGatewayService;
public void execute(WorkItem item, WorkflowSession wfsession,MetaDataMap args) throws WorkflowException {
try
{
log.info("Here in execute method"); //ensure that the execute method is invoked
//Declare a MessageGateway service
MessageGateway<Email> messageGateway;
//Set up the Email message
Email email = new SimpleEmail();
//Set the mail values
String emailToRecipients = "[email protected]";
String emailCcRecipients = "[email protected]";
email.addTo(emailToRecipients);
email.addCc(emailCcRecipients);
email.setSubject("AEM Custom Step");
email.setFrom("[email protected]");
email.setMsg("This message is to inform you that a new profile has been added. To find out about the new profile please visit our site.");
//Inject a MessageGateway Service and send the message
messageGateway = messageGatewayService.getGateway(Email.class);
// Check the logs to see that messageGateway is not null
messageGateway.send((Email) email);
}
catch (Exception e)
{
e.printStackTrace() ;
}
}
}
Do I need to give path till /content/demo/en/profile/jcr:content/par1 & change the content type? Please Suggest something So my workflow can be automated when I drag & drop my component in parsys. Thanks in advance.