Page 1 of 1

timer or due date in workflow

PostPosted:Mon Jan 16, 2017 5:11 am
by jimac
I am using JBPM 3.3.1 GA
Jboss 5.00

Good Day!

I am planning on doing this, but I don't know how.

user 1 will input the date or time, then that inputted time/date will be the basis for notifyng user2.
For example:

Due Date : 5:00pm (user 1 inputted 5pm)
submit

user 2 will see a blinking icon ( pending task ) on 5:00pm
not when user 1 click submit.
-
THUS, I need a dynamic due date

But I dont know how to set a variable in "<timer duedate="(i need to put a variable here)"
Thanks!

Re: timer or due date in workflow

PostPosted:Wed Jan 18, 2017 7:49 am
by pavila
The simplest approach to set the timer due date dynamically during process execution would be to use a process variable. This variable could be set in an ActionHandler, before the node containing the timer is reached:
Code: Select all
public class SetDueDateActionHandler implements ActionHandler {
  public void execute(ExecutionContext executionContext) throws Exception {
    Date duedate = new Date();
    // apply some date calculations
    executionContext.setVariable("calculatedDueDate", duedate);
  }
}
This variable can then be used in the duedate attribute in processdefinition.xml, using the following syntax:
Code: Select all
<timer duedate="#{calculatedDueDate}" name="mytimer">
<timer duedate="#{calculatedDueDate} + 5 days" name="mytimer">
The variable in the 'duedate' attribute (here: #{calculatedDueDate}) has to be either a java.util.Date or java.util.Calendar object.

Re: timer or due date in workflow

PostPosted:Thu Jan 19, 2017 2:33 am
by jimac
pavila wrote:The simplest approach to set the timer due date dynamically during process execution would be to use a process variable. This variable could be set in an ActionHandler, before the node containing the timer is reached:
Code: Select all
public class SetDueDateActionHandler implements ActionHandler {
  public void execute(ExecutionContext executionContext) throws Exception {
    Date duedate = new Date();
    // apply some date calculations
    executionContext.setVariable("calculatedDueDate", duedate);
  }
}
This variable can then be used in the duedate attribute in processdefinition.xml, using the following syntax:
Code: Select all
<timer duedate="#{calculatedDueDate}" name="mytimer">
<timer duedate="#{calculatedDueDate} + 5 days" name="mytimer">
The variable in the 'duedate' attribute (here: #{calculatedDueDate}) has to be either a java.util.Date or java.util.Calendar object.
Hello,

This is my code:
Code: Select all
package com.sample.action;

import java.util.Date;
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;
import com.openkm.bean.form.Input;

public class timer_duedate implements ActionHandler {
	private static final long serialVersionUID = 1L;

	@Override
	public void execute(ExecutionContext context) throws Exception {
		// input for user
		Input calculatedDueDate = (Input) context.getContextInstance().getVariable("calculatedDueDate");
		String inputted_calculatedDueDate = calculatedDueDate.getValue(); 

		 Date duedate = new Date();
		 // apply some date calculations
		 context.setVariable("inputted_calculatedDueDate", duedate);
	}
 }
The variable " inputted_calculatedDueDate" says that it is not used.

Can you correct my code ?

also,
what format should the user input for it to accept the date? ,
does this kind of format accepted?
year-month-day (2016-January-19)

or can it also accept hours only?
like
1 hour
2:45pm

something like that.
Thanks