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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Need Help regarding Custom workflow logic to Revise the (Affected/review Objects) after Released

Rohaan
13-Aquamarine

Need Help regarding Custom workflow logic to Revise the (Affected/review Objects) after Released

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??

 

 

 

 

 

ACCEPTED SOLUTION

Accepted Solutions
HelesicPetr
22-Sapphire I
(To:Rohaan)

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

View solution in original post

2 REPLIES 2
HelesicPetr
22-Sapphire I
(To:Rohaan)

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

Rohaan
13-Aquamarine
(To:HelesicPetr)

Thanks! @HelesicPetr 

Announcements

Top Tags