Initialise a default workflowDueDate

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

Initialise a default workflowDueDate

Hello,

I am asked to set a default workflowDueDate to the workflow I implement: in 10 work day after the current date.

I already have a script to calculate this default date, my issue is to set this date.

I saw 2 places where it can be down, but I need a technical advise:

1) the first place a saw I can do it is the model.xml, in my custom type of my startTask:

<overrides>
                <property name="bpm:workflowDueDate">
                          <mandatory>true</mandatory>

                          <default />
                </property>
</overrides>

but in this case I don't know how to call my script (and even if it's possible) in the model.xml

2) the second place I can imagine set this default date, will be in the bpmn:

<definitions xmlns="http://www.omg.org/.........>
     <process id="id" name="name" isExecutable="true">
          <extensionElements>
               <activiti:executionListener event="start" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
                    <activiti:field name="script">
                         <activiti:string><![CDATA[<import resource="classpath:alfresco/path/myScript.js">

></activiti:string>
                    </activiti:field>
            </activiti:executionListener>
    </extensionElements>
      <startEvent id="start" activiti:formKey="ddg:submitGroupsReviewTask"></startEvent>

       <sequenceFlow id="flow1"  .....

The issue here is:

  1. if a call my script in the <extensionElements> of the process, it's resolved after the startTask is done, so I don't have my default dueDate set when I initialise the workflow (it will rather overwrite the date set by the user).
  2. it the same if I add the script call in the <extensionElements> in the <startEvent>.

Did some one know how set a default workflowDueDate calculated by a script?

4 Replies
douglascrp
Advanced II

Re: Initialise a default workflowDueDate

Hello.

Have you tried to use the create event instead of the start one?

But I would put that on the create event for the startEvent element, and not in the process.

afaust
Master

Re: Initialise a default workflowDueDate

The type of event should not really matter - you simply need to adjust the logic, i.e. if a due date has been set, simply do not override it, otherwise generate your default. That bit of logic should be trivial...

vmiorga
Active Member II

Re: Initialise a default workflowDueDate

Initialy I had to make the due date as mandatory, that is why I overide the workflowDueDate in my model.xml.

The goal was that when the initiator start a new workflow, the default date was automatically set and visible in the start task. Add to this feature, of course the initiator should be able to change this default date.

My issue is the place where I call my script, when the call is done in the <extensionElements> of the process, the execussion of this script is donne after the completion of the start tastk. This have as consequence that the default date is not display and that the default date will erase the date set by the initiator.

I just think of a possible alternative route: remove the mandatory aspect of the workfowDueDate, and test is value in the <extensionElements> of the process. If it is null I call my script to set the default date. The negative aspect of this solution is that the user wont see the defaut due date.

But does exist a way to have a default date set when the initiator start a now workflow ( the same way I did it for a custom properties: <property name="vs:requiredApprovePercent"><type>d:int</type><default>100</default>, with the difficulty that the date is not static and is calculated by a script)?

vmiorga
Active Member II

Re: Initialise a default workflowDueDate

A point on the situation:

I made a custom date-display.ftl, which is a copy of the native file date.ftl.

In my ftl I add the script I need to calculate the default due date to set : function calc_date_mini(nbjour){ ... }

Now I would to set the result get from this function in the property value from the date input. Something like:

<input id="${controlId}-date" value=calc_date_mini(nbjour) name="-" type="text" class="date-entry" <#if field.description??>title="${field.description}"</#if> <#if disabled>disabled="true"<#else>tabindex="0"</#if>></input>#

I figure that it's no possible to call the fonction like this, so I tried whit a second script in the end of my ftl, which would set the value by retriving the element, by calling document.getElementById("${controlId}-date"), but in this case the element is null and the input value is not set.

Did someone know how I can achieve my aim?