How can Get a Workflow Process Template with name and ID information
Version: Windchill 12.1
Hello,
I want to automatically create a Promotion Request for the documents reviewed within the Change Review. I have achieved this with the code shared below. However, since I have not defined any workflow process in the Promotion Notice, no workflow starts. For this, I reached the method shared below. However, I cannot figure out how to obtain the WfProcessTemplate. I have the name and ID of this template, but I couldn't retrieve the template using them.
Code for creating the Promotion Request:
wt.pom.Transaction trx = new wt.pom.Transaction();
wt.change2.WTChangeReview changeReview = (wt.change2.WTChangeReview) primaryBusinessObject;
// Retrieve the container from the ChangeReview object
wt.inf.container.WTContainer container = changeReview.getContainer();
wt.inf.container.WTContainerRef containerRef = wt.inf.container.WTContainerRef.newWTContainerRef(container);
// Retrieve the affected documents from the ChangeReview object
wt.fc.QueryResult queryResult = wt.change2.ChangeHelper2.service.getChangeables(changeReview);
wt.fc.collections.WTSet set = new wt.fc.collections.WTHashSet();
while (queryResult.hasMoreElements()) {
wt.doc.WTDocument document = (wt.doc.WTDocument) queryResult.nextElement();
set.add(document); // Add WTDocument objects to the collection
}
try {
trx.start();
wt.maturity.MaturityBaseline maturityBaseline = wt.maturity.MaturityBaseline.newMaturityBaseline();
maturityBaseline.setContainerReference(containerRef);
maturityBaseline = (wt.maturity.MaturityBaseline)wt.fc.PersistenceHelper.manager.save(maturityBaseline);
wt.maturity.PromotionNotice pn = wt.maturity.PromotionNotice.newPromotionNotice("Custom_Promotion_Request");
pn.setPromotionDate(new java.sql.Timestamp(System.currentTimeMillis()));
pn.setContainer(container);
pn.setContainerReference(containerRef);
pn.setMaturityState(wt.lifecycle.State.toState("RELEASED"));
pn.setDescription("theDescription");
pn.setConfiguration(maturityBaseline);
wt.vc.baseline.BaselineHelper.service.addToBaseline(set, pn.getConfiguration());
pn = wt.maturity.MaturityHelper.service.savePromotionNotice(pn);
wt.maturity.MaturityHelper.service.savePromotionTargets(pn, set);
trx.commit();
trx = null;
} finally {
if (trx != null) {
trx.rollback();
}
}
Code for starting the Promotion Notice with a process:
wt.maturity.MaturityService.startPromotionProcess(PromotionNotice, WfProcessTemplate)

