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:
Did some one know how set a default workflowDueDate calculated by a script?
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.
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...
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)?
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?
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.