cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Translate the entire conversation x

Setting Workflow Activity Deadline on-the-fly

dgraham-4
1-Visitor

Setting Workflow Activity Deadline on-the-fly

PDMLink 8.0 M020

Does anyone know if it is possible to set the "deadline" for a workflow
activity on-the-fly?

We have a very simple workflow for a small group. There are no change
objects involved. Just a WTDocument. We want a manager to receive a
review task. In that task we want the manager to enter a due date and
have this due date passed to the "deadline" of a subsequent activity that
will be performed by an engineer.

My guess is that this will not be possible but if anyone has any ideas I'd
appreciate their feedback.

Thanks in advance,

David
3 REPLIES 3

This sorta thing is done all the time.

Have a variable at process level store the due date as a string and then update the workitem/activity using persistencehelper api via a workflow task transition 'start' in the engineers task. If no one else had a snippet handy. I'll write you an example.

Regards,
Dave



Sent from my Verizon Wireless BlackBerry

I have a snippet that creates or updates a Timestamp object (which I added to the ChangeIssue definition), and initialises it with a computed value.

Beware, it fails on 9.1, and I haven't yetfound why.

HTH,

Vincent

long resolutionDelay = DelaiPourInconnu; //délai sévérité inconnue
String severite = ChangeIssue.getIssuePriority().toString();
if (severite.equals("MINOR")) resolutionDelay = DelaiPourMineur; else
if (severite.equals("MEDIUM")) resolutionDelay = DelaiPourMoyen; else
if (severite.equals("SEVERE")) resolutionDelay = DelaiPourSevere; else
if (severite.equals("SHOWSTOPPER")) resolutionDelay = DelaiPourBloquant;

java.sql.Timestamp dueDate = new java.sql.Timestamp(System.currentTimeMillis()+86400*1000*resolutionDelay);
wt.change2.WTChangeIssue RPCourant = (wt.change2.WTChangeIssue) primaryBusinessObject;

// RPCourant.setDescription( "Trace " + RPCourant.getDescription()) ;
wt.iba.value.IBAHolder ibaHolder = (wt.iba.value.IBAHolder) RPCourant;
ibaHolder = wt.iba.value.service.IBAValueHelper.service.refreshAttributeContainer(ibaHolder, null, null, null);
wt.iba.value.DefaultAttributeContainer defAttCont = (wt.iba.value.DefaultAttributeContainer) ibaHolder.getAttributeContainer();

wt.iba.definition.litedefinition.TimestampDefView attDef = (wt.iba.definition.litedefinition.TimestampDefView)wt.iba.definition.service.IBADefinitionHelper.service.getAttributeDefDefaultViewByPath(NomChampDueDate);
// positioner la due date si elle n'existe pas encore
if (defAttCont.getAttributeValues(attDef).length==0)
{
wt.iba.value.litevalue.TimestampValueDefaultView newValue=new wt.iba.value.litevalue.TimestampValueDefaultView(attDef,dueDate );
defAttCont.addAttributeValue(newValue);
}
wt.fc.PersistenceHelper.manager.save((wt.fc.Persistable) RPCourant);



In Reply to Dave DeMay:

This sorta thing is done all the time.

Have a variable at process level store the due date as a string and then update the workitem/activity using persistencehelper api via a workflow task transition 'start' in the engineers task. If no one else had a snippet handy. I'll write you an example.

Regards,
Dave



Sent from my Verizon Wireless BlackBerry
imendiola
13-Aquamarine
(To:dgraham-4)

Hi David,

once you get the values from the first task, you can use this code for the second task.

WfAssignedActivity wfActivity = (WfAssignedActivity) self.getObject(); 
// Set deadline to the Task
// Get the miliseconds with 2 operations, because with only one, and more than 29 days
// if crashes returning negative values.
long deadlineMillsToAdd = ((((days * 24) + hours) * 60) + minutes) * 60;
deadlineMillsToAdd = deadlineMillsToAdd * 1000;
long deadlineInMillis = wfActivity.getStartTime().getTime() + deadlineMillsToAdd;
wfActivity.setDeadline(new Timestamp(deadlineInMillis + 1000));
WfEventConfiguration wfEventConfiguration = wfActivity.getEventConfiguration();
wfEventConfiguration.setOverdueAction(WfOverdueActionType.SKIP, true); // The event type you need to fire if deadline applies
wfActivity.setEventConfiguration(wfEventConfiguration);
PersistenceHelper.manager.save(wfActivity);
// To get the SKIP Transition when event occurs...
WfEngineServerHelper.service.queueDeadlineCheck(wfActivity);

Hope that this could help.

Regards...

Iker Mendiola

Prambanan IT Services
http://www.prambanan-it.com



http://www.prambanan-it.comIker Mendiola - Prambanan IT Services
Announcements
Top Tags