Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
Hello,
I need help regarding logic to Change the Revision for the Change Review Objects through my custom Workflow. Is there any API to get this done so the Objects are revised once they are in Released State??
Solved! Go to Solution.
Hello @Rohaan
I can help you with a code to revise object.
This example shows how to revise WTDocument, but it can revise whatever you need.
revise code
private WTDocument createNewRevision(WTDocument wtObject) throws WTException
{
//com.ptc.windchill.enterprise.maturity.PromotionNoticeWorkflowHelper.revisePromotables(pn, pn.getCreator(), locale);
try
{
WTCollection revisionables = new WTArrayList();
revisionables.add(wtObject);
WTPrincipalReference principalRef = SessionHelper.manager.getPrincipalReference();
WTValuedMap newVersions = VersionControlHelper.service.newVersions(revisionables);
WTCollection newWtRevision = newVersions.wtValues();
setIterationCreator(newWtRevision, principalRef);
WTCollection newVersionColect = PersistenceHelper.manager.store(newWtRevision);
if (newVersionColect.size() > 0)
{
WTArrayList wtArrayList = new WTArrayList(newVersionColect);
ObjectReference wtPreference = (ObjectReference) wtArrayList.get(0);
wtObject = (WTDocument) wtPreference.getObject();
}
} catch (WTPropertyVetoException var9)
{
throw new WTException(var9);
}
return wtObject;
}
private static void setIterationCreator(WTCollection var0, WTPrincipalReference var1) throws WTException, WTPropertyVetoException
{
if (var1 != null)
{
Iterator var2 = var0.persistableIterator();
while (var2.hasNext())
{
Promotable var3 = (Promotable) var2.next();
VersionControlHelper.assignIterationCreator(var3, var1);
VersionControlHelper.setIterationModifier(var3, var1);
}
} else if (logger.isDebugEnabled())
{
logger.debug("The given principal reference is null");
}
}
PetrH
Hello @Rohaan
I can help you with a code to revise object.
This example shows how to revise WTDocument, but it can revise whatever you need.
revise code
private WTDocument createNewRevision(WTDocument wtObject) throws WTException
{
//com.ptc.windchill.enterprise.maturity.PromotionNoticeWorkflowHelper.revisePromotables(pn, pn.getCreator(), locale);
try
{
WTCollection revisionables = new WTArrayList();
revisionables.add(wtObject);
WTPrincipalReference principalRef = SessionHelper.manager.getPrincipalReference();
WTValuedMap newVersions = VersionControlHelper.service.newVersions(revisionables);
WTCollection newWtRevision = newVersions.wtValues();
setIterationCreator(newWtRevision, principalRef);
WTCollection newVersionColect = PersistenceHelper.manager.store(newWtRevision);
if (newVersionColect.size() > 0)
{
WTArrayList wtArrayList = new WTArrayList(newVersionColect);
ObjectReference wtPreference = (ObjectReference) wtArrayList.get(0);
wtObject = (WTDocument) wtPreference.getObject();
}
} catch (WTPropertyVetoException var9)
{
throw new WTException(var9);
}
return wtObject;
}
private static void setIterationCreator(WTCollection var0, WTPrincipalReference var1) throws WTException, WTPropertyVetoException
{
if (var1 != null)
{
Iterator var2 = var0.persistableIterator();
while (var2.hasNext())
{
Promotable var3 = (Promotable) var2.next();
VersionControlHelper.assignIterationCreator(var3, var1);
VersionControlHelper.setIterationModifier(var3, var1);
}
} else if (logger.isDebugEnabled())
{
logger.debug("The given principal reference is null");
}
}
PetrH