Quantcast
Channel: PTC Community: Message List - Windchill
Viewing all articles
Browse latest Browse all 8876

Re: Maintaining Rev History in Drawings

$
0
0

Andy,

 

We do exactly the thing you describe in one of our workflow.  Get the user how validate a worflow "signature" task

In your workflow signature task, in the transition tab, "terminate" transition ,  you can add java code to get the user how execute the task, then get the drawing, and update its parameter IBA

may be this code will not compile  as is ... a best practice is to use an extrenal class and call it in the workflow. Not to use too much java code directly in the robots ....

 

 

// get the user how perform the workflow task

WfAssignedActivity activity= (wt.workflow.work.WfAssignedActivity)self.getObject();

java.util.Enumeration allassig2 = activity.getAssignments();

while (allassig2.hasMoreElements())
{
Object a2= allassig2.nextElement();
java.util.Enumeration balots = ((wt.workflow.work.WfAssignment)a2).getBallots();
while (balots .hasMoreElements())
{
Object bal= balots .nextElement();

// here is the user how perform the task
  wt.org.WTPrincipalReference user_ref= ((WfBallot)bal).getVoter();

}      
}

 

//get the CAD drawing  , here in my case I'm in a Change Activity workflow.  But if your workflow is directly on the lifecycle of xour CADDoc , it is easyiest.  The CADDoc will the the primaryBusinessObject variable of the workflow

 

wt.fc.QueryResult changeables = wt.change2.ChangeHelper2.service.getChangeablesAfter((wt.change2.WTChangeActivity2)primaryBusinessObject,true);
while (changeables.hasMoreElements())
        {
         wt.change2.Changeable2 cb = (wt.change2.Changeable2)changeables.nextElement();
         if (cb instanceof wt.epm.EPMDocument)
         {

if (((wt.epm.EPMDocument)cb).getDocType().equals(wt.epm.EPMDocumentType.toEPMDocumentType("CADDRAWING")))
  {
         String fullname = user_ref.getPrincipal().getFullName();

 

 

  // update the IBA "APPROVED_BY"

LWCNormalizedObject obj=

null;try {

Locale locale = SessionHelper.getLocale();

obj =

new LWCNormalizedObject((Persistable) cb, null, locale, new UpdateOperationIdentifier());

 

}

catch (WTException e) {

e.printStackTrace();

}

obj.load("APPROVED_BY");

obj.set("APPROVED_BY", fullname);

obj.apply();

PersistenceServerHelper.

manager.update((Persistable) cb);

 

 

// after updating the IBA, may be you have to republish the drawing in worker with the new value for the APPROVER.

If your worker is configured to publish on a lifecyle state change , and there's a SetState "RELEASED" robot after that in your workflow, no need to do that ...
  
   }


}
}


Viewing all articles
Browse latest Browse all 8876

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>