Resend workflow email notification

cancel
Showing results for 
Search instead for 
Did you mean: 
imanez1
Active Member II

Resend workflow email notification

Jump to solution

Hello,

I have an activiti workflow that i start with this function:

function startWorkflow(assigneePerson)
{
    var workflow = actions.create("start-workflow");
    workflow.parameters.workflowName = "activiti$activitiWorkflow";
    workflow.parameters["bpm:assignee"] = assigneePerson;
    var futureDate = new Date();
    futureDate.setDate(futureDate.getDate() +7);
    workflow.parameters["bpm:workflowDueDate"] = futureDate; 
    workflow.parameters["bpm:sendEMailNotifications"] = true;
    return workflow.execute(document);
}

I want the assignee to receive until the due date (during those 7 days) each day a daily reminder to do the task assigned.

How can I do that?

I tried the following:

<process id="activitiWorkflow" name="Review process">

        <startEvent id="start" name="Submit Review Task"
            activiti:formKey="wfa:submitReviewTaskk" />

        <sequenceFlow id='flow1' 
            sourceRef='start'
            targetRef='reviewTask' />

        <userTask id="reviewTask" name="Autorisation"
            activiti:formKey="wfa:activitiReviewTaskk">

        </userTask>
<endEvent id="end" />
 <boundaryEvent id="sid-E18EA6BC-64EC-4511-B9EF-01D8152829AE" attachedToRef="reviewTask" cancelActivity="false">
      <timerEventDefinition>
        <timeCycle>R6/PT24H</timeCycle>
      </timerEventDefinition>
    </boundaryEvent>

    </process>
1 Solution

Accepted Solutions
imanez1
Active Member II

Re: Resend workflow email notification

Jump to solution

Hello, 

I tried the following and it works!!

<process id="activitiWorkflow" name="Review process">

        <startEvent id="start" name="Submit Review Task"
            activiti:formKey="wfa:submitReviewTaskk" />

        <sequenceFlow id='flow1' 
            sourceRef='start'
            targetRef='reviewTask' />

        <userTask id="reviewTask" name="Autorisation"
            activiti:formKey="wfa:activitiReviewTaskk">
 <extensionElements>
               <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                        if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate
                        if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
               <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                            .......
                     </activiti:string>
                  </activiti:field>
                  <activiti:field name="runAs">  
                     <activiti:string>admin</activiti:string>  
                  </activiti:field> 
               </activiti:taskListener>
           </extensionElements>
            <humanPerformer>
                <resourceAssignmentExpression>
                    <formalExpression>${bpm_assignee.properties.userName}</formalExpression>
                </resourceAssignmentExpression>
            </humanPerformer>
        </userTask>
<endEvent id="end" />
<boundaryEvent id="timer_review" name="Timer" attachedToRef="reviewTask" cancelActivity="false"> <timerEventDefinition> <timeCycle>R/PT1M</timeCycle> </timerEventDefinition>
</boundaryEvent> <serviceTask id="mailtask_review" name="E-mail Reminder" activiti:class="org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate"> <extensionElements> <activiti:field name="script"> <activiti:string> logger.log("E-mail reminder sent"); <!-- Send e-mail reminder if assignee defined--> if (bpm_assignee != null) { var mail = actions.create("mail"); mail.parameters.to = bpm_assignee.properties.email; mail.parameters.subject = "Subject"; mail.parameters.text = "Reminder task test"; mail.execute(bpm_package.children[0]); logger.log("E-mail reminder sent"); } </activiti:string> </activiti:field> </extensionElements> </serviceTask> <sequenceFlow id="flow7" sourceRef="timer_review" targetRef="mailtask_review"></sequenceFlow> </process>

 

 

 

View solution in original post

3 Replies
abbask01
Senior Member

Re: Resend workflow email notification

Jump to solution

Add an alfresco script task linked to your timer boundary event and add your send email action in that script. put an end event after the script task. you can set variables with Listener to be used in the script task for triggering the mail action.

Be sure to uncheck cancelActivity flag in your Boundary Event.

Regards,
Abbas
imanez1
Active Member II

Re: Resend workflow email notification

Jump to solution

Hello, 

I tried the following and it works!!

<process id="activitiWorkflow" name="Review process">

        <startEvent id="start" name="Submit Review Task"
            activiti:formKey="wfa:submitReviewTaskk" />

        <sequenceFlow id='flow1' 
            sourceRef='start'
            targetRef='reviewTask' />

        <userTask id="reviewTask" name="Autorisation"
            activiti:formKey="wfa:activitiReviewTaskk">
 <extensionElements>
               <activiti:taskListener event="create" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                        if (typeof bpm_workflowDueDate != 'undefined') task.dueDate = bpm_workflowDueDate
                        if (typeof bpm_workflowPriority != 'undefined') task.priority = bpm_workflowPriority;
                     </activiti:string>
                  </activiti:field>
               </activiti:taskListener>
               <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
                  <activiti:field name="script">
                     <activiti:string>
                            .......
                     </activiti:string>
                  </activiti:field>
                  <activiti:field name="runAs">  
                     <activiti:string>admin</activiti:string>  
                  </activiti:field> 
               </activiti:taskListener>
           </extensionElements>
            <humanPerformer>
                <resourceAssignmentExpression>
                    <formalExpression>${bpm_assignee.properties.userName}</formalExpression>
                </resourceAssignmentExpression>
            </humanPerformer>
        </userTask>
<endEvent id="end" />
<boundaryEvent id="timer_review" name="Timer" attachedToRef="reviewTask" cancelActivity="false"> <timerEventDefinition> <timeCycle>R/PT1M</timeCycle> </timerEventDefinition>
</boundaryEvent> <serviceTask id="mailtask_review" name="E-mail Reminder" activiti:class="org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate"> <extensionElements> <activiti:field name="script"> <activiti:string> logger.log("E-mail reminder sent"); <!-- Send e-mail reminder if assignee defined--> if (bpm_assignee != null) { var mail = actions.create("mail"); mail.parameters.to = bpm_assignee.properties.email; mail.parameters.subject = "Subject"; mail.parameters.text = "Reminder task test"; mail.execute(bpm_package.children[0]); logger.log("E-mail reminder sent"); } </activiti:string> </activiti:field> </extensionElements> </serviceTask> <sequenceFlow id="flow7" sourceRef="timer_review" targetRef="mailtask_review"></sequenceFlow> </process>

 

 

 

SalvoDev
Member II

Re: Resend workflow email notification

Jump to solution

is it possible to add custom notification date, 10, 5 or 2 days before to the email notification? Thank you