cancel
Showing results for 
Search instead for 
Did you mean: 

bpm_workflowDueDate

gslamy
Champ in-the-making
Champ in-the-making
Hello!

I have some problem with start my task in date from "bpm_workflowDueDate" field.
I tried to get this date from "bpm_workflowDueDate" field:

   <startEvent id="startevent" name="Start" activiti:initiator="initiator" activiti:formKey="scwf:startstaff"> 
      <extensionElements>
        <activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
          <activiti:field name="script">
            <activiti:string>      
               <![CDATA[execution.setVariable('startdate', task.getVariableLocal('bpm_workflowDueDate'));]]>
            </activiti:string>
          </activiti:field>
        </activiti:taskListener>
      </extensionElements>
    </startEvent>

Now I want to start next task in this date from variable "startdate-3 days". I tried to add a timer, but I think it has a different date format and doesn't work.
7 REPLIES 7

vasile_dirla
Star Contributor
Star Contributor
Hi,
could you create a unit test for it?
http://forums.activiti.org/content/sticky-how-write-unit-test

if you provide such a unit test will be easier for all the community members to understand what are you trying to do (and how); and then will be also easier to help.

gslamy
Champ in-the-making
Champ in-the-making
I am newbie. I can't do it, but I need in an example how to get duedate and start some task in this date.

vasile_dirla
Star Contributor
Star Contributor
If you'll write a unit test there are 90% chances to solve the problem by yourself, and even more, next time you'll know exactly how to write such a unit test. (it's a good exercise)

just put a breakpoint inside the ScriptTaskListener class and inspect the variables and then you'll see exactly what's happening.

for writing the unit test you can follow the steps from this link: http://www.jorambarrez.be/blog/2012/09/24/how-to-write-a-unit-test/

gslamy
Champ in-the-making
Champ in-the-making
But I don't get errors. I don't know how to calculate number of days from "bpm_workflowDueDate" field (I use Alfresco 5.0.d). I want to run the task in this day. That is, I need to get the number of days and use timer.

vasile_dirla
Star Contributor
Star Contributor
what type is "bpm_workflowDueDate"  variable ?
if it's java.util.Date then you could do it like that: (by using joda time)
<code>
Interval interval = new Interval(oldTime, new Instant());
</code>
or
<code>
int diffInDays = (int)( (newerDate.getTime() - olderDate.getTime())
                 / (1000 * 60 * 60 * 24) )
</code>

if it's a string, then you should convet it to Date first of all.

gslamy
Champ in-the-making
Champ in-the-making
But how to calculate the number of days?
1. I must get current date.
2. I must get date from Alfresco user task.
3. Calculate number fo days between current date and user task date to get duration (i.e. P10D).

vasile_dirla
Star Contributor
Star Contributor
Yes, you ate right these are the steps.
The number of days between 2 dates is the number on milisecconds / milisecconds in a day.
See my prev post