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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

I want to find the previous version of the part which is having version as AA alphabetic

ashiq_097
5-Regular Member

I want to find the previous version of the part which is having version as AA alphabetic

Version: Windchill 12.0

 

Use Case: i was using allversionsfrom(Versioned versioned) to fetch the all versions as to first record version. But for alphabetic version like AA AB im not getting the previous version, please assist


Description:

i was using allversionsfrom(Versioned versioned) to fetch the all versions as to first record version. But for alphabetic version like AA AB im not getting the previous version, please assist

8 REPLIES 8
HelesicPetr
22-Sapphire I
(To:ashiq_097)

Hi @ashiq_097 

Please share what configuration do you use for the versioning schema.

What do you expect and what you get. for example, I want the previous version from AB and I do not get AA please describe it more widely 

How the code is written? It could help to test it and help you.

PetrH

ashiq_097
5-Regular Member
(To:HelesicPetr)

hi @HelesicPetr thanks for your response.. we have revision as Double Alphabetic characters as i was trying to use below snippet code to extract the previous released revision details but I'm getting only AB Version in the result.. please assist

public static WTPart getPreviousRevision(RevisionControlled object) {
LOGGER.debug("Enter -->getPreviousRevision");
RevisionControlled retValue = null;
WTPart prevVersion = null;
String actualRev = object.getVersionIdentifier().getVersionSortId();
 
try{
QueryResult allVersions = VersionControlHelper.service.allVersionsFrom(object);
RevisionControlled prevRevision = null;
while (allVersions.hasMoreElements()) {
    Object obj = allVersions.nextElement();
    if (obj instanceof RevisionControlled) {
    String checkRevision = ((RevisionControlled) obj).getVersionIdentifier().getVersionSortId();
    if (checkRevision.equals(actualRev)){
    // next version
    }else{
    RevisionControlled subprevRevision = (RevisionControlled) obj;
    State state = subprevRevision.getLifeCycleState();
    if (state.equals(State.toState("RELEASED"))) {
    prevRevision = subprevRevision;
    break;
    }else{
    actualRev = subprevRevision.getVersionIdentifier().getVersionSortId(); 
    }
    }
    }
}
if (prevRevision != null)
{
retValue = prevRevision;
prevVersion = (WTPart)retValue;
}
}catch (WTException e){
LOGGER.error("getPreviousRevision - Resulting ObjectsPOC" + e);
}
LOGGER.debug("Exit -->getPreviousRevision");
return prevVersion;
}

part_detailsPNG.PNG

HelesicPetr
22-Sapphire I
(To:ashiq_097)

Hi @ashiq_097 

The method VersionControlHelper.service.allVersionsFrom(object); returns just the latest objects of all revisions.

So this method can not be used to get non latest version. 

 

if you want to get non latest version then you have to use following method. 

QueryResult allVersions = VersionControlHelper.service.allIterationsOf(object.getMaster());

 

PetrH

ashiq_097
5-Regular Member
(To:HelesicPetr)

hi @HelesicPetr , I wanted to  pull the latest object details but using the method allVersionsFrom i was getting empty data for the previous revision on this Double Alphabetic version details as pasted the screenshot above.  I Accept this method is pulling correct data for single alphabetic , numeric versions. only issue is with double alphabetic is not pulling the correct details as needed. please assist 

ashiq_097
5-Regular Member
(To:ashiq_097)

using alliterationsof will be moving pulling non-latest objects which has other views like manufacturing , but i want to return only engineering view part details , is that possible to fetch it ?

HelesicPetr
22-Sapphire I
(To:ashiq_097)

Hi @ashiq_097 

You have to filter the result by your own conditions

Or you can use qyery definition and search method where you can define own conditions. 

PetrH

ashiq_097
5-Regular Member
(To:HelesicPetr)

is there any API to Pull this versions as well ?

Hello @ashiq_097

 

It looks like you have some responses from a community member. If any of these replies helped to answer your question please mark the appropriate reply as the Accepted Solution. 

Of course, if you have more to share on your issue, please let the Community know so other community members can continue to help you.

Thanks,
Vivek N.
Community Moderation Team.

Top Tags