0
votes

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.

1
Did you not set a workflow in the launcher?Florian Salihovic

1 Answers

0
votes

Have you verified your settings in the launcher page indeed? Go to localhost:4502/libs/cq/workflow/content/console.html and select the 4th tab (Launcher). Can you see an entry with your workflow and a particular event type? Please note you can use the workflow page as well to verify whether a workflow ran. Good luck.