Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
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
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
![]() | Iker Mendiola - Prambanan IT Services |
