cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow Timer DueDate issue

aswini
Champ in-the-making
Champ in-the-making
Using an expression for defining due date for creating Timers in Workflow is not working. Any ideas how to use expressions in specifying due date for a timer.

In my processdefinition xml, if I use:

<timer name="sendMail" duedate="#{bpm_workflowDueDate} - 1 business days"> or
<timer name="sendMail" duedate="#{bpm_workflowDueDate} - 1 days">

Error:
Caused by: org.alfresco.service.cmr.workflow.WorkflowException: duedate expression must evaluate to a date

Please help!!!!

Regards
Aswini
6 REPLIES 6

jayjayecl
Confirmed Champ
Confirmed Champ
Maybe you should try to define the date with a script / variable as

<variable name="theDate" access="read,write"/>
      <expression>
         // build your date theDate right here in JS;
      </expression>

aswini
Champ in-the-making
Champ in-the-making
Maybe you should try to define the date with a script / variable as

<variable name="theDate" access="read,write"/>
      <expression>
         // build your date theDate right here in JS;
      </expression>



So, I tried something like:
<variable name="theDate" access="read,write"/>
      <expression>
         bpm_workflowDueDate + 1;
      </expression>

I am still receiving the same error!!

jayjayecl
Confirmed Champ
Confirmed Champ
As you see in the following example, your syntax seems not to be correct :

http://wiki.alfresco.com/wiki/Workflow_Reqs_and_Design#Start_Workflow_Action

maybe (although I'm no expert):


var theDate = new Date();
theDate.setDate(bpm_workflowDueDate.getDate() + 1);  // 1 means 1 day

aswini
Champ in-the-making
Champ in-the-making
Thanks.. will try and get back!!

jayjayecl
Confirmed Champ
Confirmed Champ
Ok,

but as it's 99% sure you will still have an error, please paste your whole processDef next time Smiley Wink

aswini
Champ in-the-making
Champ in-the-making
I am posting my processdefinition xml. I am still having issues assigning the Email notification date (theDate) to duedate -1.


<script>
            <variable name="theDate" access="read,write"/>
                  <expression>
                     var theDate = new Date();
                     theDate.setDate(bpm_workflowDueDate.getDate()-1); or even theDate.setDate(theDate.getDate()-1);
                  </expression>
            </script>


    <swimlane name="initiator"></swimlane>

    <start-state name="start">
        <task name="wf:submitGroupReviewTask" swimlane="initiator" />
        <transition name="" to="startreview"/>
    </start-state>

    <node name="startreview">
        <action class="org.alfresco.repo.workflow.jbpm.ForEachFork">
            <foreach>#{people.getMembers(bpm_groupAssignee)}</foreach>
            <var>reviewer</var>
        </action>
        <event type="node-enter">
            <script>
                <variable name="wf_approveCount" access="write" />
                <expression>
                    wf_approveCount = 0;
                </expression>
            </script>
        </event>
        <transition name="review" to="review" />
    </node>
    <task-node name="review">
        <task name="wf:reviewTask">
             <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
                <actor>#{reviewer}</actor>
            </assignment>
           
<!– This is the code added on your recommendation. But it doesnt work and am still getting errors–>
           <event type="node-enter">
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
            <variable name="theDate" access="read,write"/>
                  <expression>
                     var theDate = new Date();
                     theDate.setDate(bpm_workflowDueDate.getDate()-1);
                  </expression>
            </script>
            </action>
            </event>
            <timer name="sendMail" duedate="theDate">
                <action name="sendMail" class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                 <script>
                     var mail = actions.create("mail");
                     var template = companyhome.childByNamePath("…");
                     var txtMail = bpm_package.children[0].processTemplate(template);
                     mail.parameters.to = reviewer.properties.email;
                     mail.parameters.from = "alfresco@alfresco.com";
                     mail.parameters.subject = "Please Review this Document";           
                     mail.parameters.text=txtMail;
                     mail.execute(bpm_package);
                 </script>
                </action>
            </timer>
           
            <timer name="OverdueApprove" duedate="#{bpm_workflowDueDate}" transition="approve">
                 <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                   <script>
                           if (logger.isLoggingEnabled())
                                 logger.log("Timer expired - approving");
                   </script>
                 </action>
            </timer>
           
            <event type="task-create">
                <script>
                    if (bpm_workflowDueDate != void) taskInstance.dueDate = bpm_workflowDueDate;
                    if (bpm_workflowPriority != void) taskInstance.priority = bpm_workflowPriority;
                </script> 
            </event>
            <event type="task-end">
               <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                  <script>
                     <variable name="bpm_assignee" access="write"/>
                     <expression>
                        if (taskInstance.actorId != null)
                           people.getPerson(taskInstance.actorId);
                        else
                           person;
                     </expression>
                  </script>
               </action>
            </event>
        </task>
        <transition name="reject" to="endreview" ></transition>
        <transition name="approve" to="endreview">
            <script>
                <variable name="wf_approveCount" access="read,write" />
                <expression>wf_approveCount = wf_approveCount +1;</expression>
            </script>
        </transition>
     
    </task-node>
     <join name="endreview">
        <transition to="isapproved" />
    </join>

    <decision name="isapproved">
        <event type="node-enter">
           <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
              <script>
                 <variable name="wf_reviewerCount" access="write"/>
                 <expression>people.getMembers(bpm_groupAssignee).length;</expression>
              </script>
           </action>
           <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
              <script>
                 <variable name="wf_requiredPercent" access="write"/>
                 <expression>wf_requiredPercent = wf_requiredApprovePercent;</expression>
              </script>
           </action>
           <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
              <script>
                 <variable name="wf_actualPercent" access="write"/>
                 <expression>wf_actualPercent = ((wf_approveCount * 100) / people.getMembers(bpm_groupAssignee).length);</expression>
              </script>
           </action>
       
        </event>
        <transition name="reject" to="rejected" />
        <transition name="approve" to="approved">
            <condition>#{wf_actualPercent >= wf_requiredPercent}</condition>
        </transition>
    </decision>
   
              
    <task-node name="rejected">
        <task name="wf:rejectedParallelTask" swimlane="initiator" />
        <transition to="end" />
    </task-node>

    <task-node name="approved">
        <task name="wf:approvedParallelTask" swimlane="initiator" />
        <transition to="end" />
    </task-node>

    <end-state name="end"/>
</process-definition>

If anybody could help pls!

Regs
Aswini