Skip to main content
8-Gravel
July 11, 2024
Question

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

  • July 11, 2024
  • 2 replies
  • 1517 views

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

2 replies

HelesicPetr
22-Sapphire II
22-Sapphire II
July 11, 2024

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_0978-GravelAuthor
8-Gravel
July 16, 2024

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 II
22-Sapphire II
July 16, 2024

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

Community Moderator
July 18, 2024

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.