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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Can any one tell me how I can delete Latest Iteration of WTDocument

ptc-3953915
1-Visitor

Can any one tell me how I can delete Latest Iteration of WTDocument

Hello,

I am stuck in one place I guess any one of you can help me, basically I am trying to delete the latest Iteration of the WTDocument using

PersistenceHelper.manager.delete(persistable);

where persistable object is latest iteration of WTDocument but when I execute the method it delete the entire version of the object

Can any one help me how I can delete only latest iteration of object

ACCEPTED SOLUTION

Accepted Solutions
rmk
7-Bedrock
7-Bedrock
(To:ptc-3953915)

Hi Ankit,

You can use the following Code to delete the latest iteration,

wt.vc.wip.Workable iterationObj = null;

boolean isLatestIteration = false;

wt.fc.QueryResult result = wt.vc.VersionControlHelper.service.allIterationsFrom((wt.vc.Iterated)WTObject);

while (result.hasMoreElements() ){

WTObject tmpObj = (WTObject)result.nextElement();

if(WTObject instanceof WTPart){


WTPart part = (WTPart)tmpObj;

isLatestIteration = part.isLatestIteration();

if(isLatestIteration){

iterationObj(part);

break;

}

}

}

if( isLatestIteration ){


wt.vc.VersionControlHelper.service.deleteIterations((wt.vc.Iterated)iterationObj,(wt.vc.Iterated)iterationObj);





strLogger.append(" :: Object Deleted :: Yes" );

}

BR

MKR

View solution in original post

2 REPLIES 2

Take a look at VersionControlHelper.service.deleteIterations. Not sure if theres a deleteLatest, so getting the iteration you want to delete may be up to you.

Message was edited by: Matthew Knight. Fixed typo

rmk
7-Bedrock
7-Bedrock
(To:ptc-3953915)

Hi Ankit,

You can use the following Code to delete the latest iteration,

wt.vc.wip.Workable iterationObj = null;

boolean isLatestIteration = false;

wt.fc.QueryResult result = wt.vc.VersionControlHelper.service.allIterationsFrom((wt.vc.Iterated)WTObject);

while (result.hasMoreElements() ){

WTObject tmpObj = (WTObject)result.nextElement();

if(WTObject instanceof WTPart){


WTPart part = (WTPart)tmpObj;

isLatestIteration = part.isLatestIteration();

if(isLatestIteration){

iterationObj(part);

break;

}

}

}

if( isLatestIteration ){


wt.vc.VersionControlHelper.service.deleteIterations((wt.vc.Iterated)iterationObj,(wt.vc.Iterated)iterationObj);





strLogger.append(" :: Object Deleted :: Yes" );

}

BR

MKR

Announcements


Top Tags