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

Need to pass the number, iteration and the version of my document to a query. But I'm not getting to version.

SOLVED
Newbie

Need to pass the number, iteration and the version of my document to a query. But I'm not getting to version.

Hi,

Need to pass the number, iteration and the version of my document to a query.

But I'm not getting to version.

How can I do this?

My code:

public static void main(String[] args) throws WTException {

wt.doc.WTDocument document = null;

String number = "C121-0019";

String version = "A";

wt.query.QuerySpec qs = new wt.query.QuerySpec(wt.doc.WTDocument.class);

qs.setAdvancedQueryEnabled(true);

qs.appendWhere(new wt.query.SearchCondition(wt.doc.WTDocument.class,

"master>number", wt.query.SearchCondition.LIKE, number),

new int[] { 0 });

qs.appendAnd();

qs.appendWhere(new wt.query.SearchCondition(wt.doc.WTDocument.class, "iterationInfo.latest" , "TRUE"), new int[] { 0 });

qs.appendAnd();

qs.appendWhere(new wt.query.SearchCondition(wt.doc.WTDocument.class,

WTDocument.VERSION_DISPLAY_IDENTIFIER, wt.query.SearchCondition.EQUAL, version));

wt.fc.QueryResult qr = wt.fc.PersistenceHelper.manager.find(qs);

System.out.println("Query : "+ qs);

if (qr.size() > 0) {

while (qr.hasMoreElements()) {

System.out.println("Query: " + qr.hasMoreElements());

document = (wt.doc.WTDocument) qr.nextElement();

System.out.println("Número do documento= "

+ document.getNumber());

System.out.println("Revisão do documento = "

+ document.getVersionIdentifier().getValue());

System.out.println("Iteração do documento = "

+ document.getIterationIdentifier().getValue());

System.out.println("Estado do documento = "

+ document.getState());

break;

}

}else{

System.out.println("Não encontrou registro: " + qr.size());

}

}

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Need to pass the number, iteration and the version of my document to a query. But I'm not getting to version.

You can try following (with modification to wt.doc.WTDocument)

String partRevision="B";

qs.appendAnd();

qs.appendWhere( new wt.query.SearchCondition(wt.part.WTPart.class, wt.vc.Versioned.VERSION_IDENTIFIER+"."+wt.vc.VersionIdentifier.VERSIONID,wt.query.SearchCondition.EQUAL,partRevision));

2 REPLIES 2

Re: Need to pass the number, iteration and the version of my document to a query. But I'm not getting to version.

You can try following (with modification to wt.doc.WTDocument)

String partRevision="B";

qs.appendAnd();

qs.appendWhere( new wt.query.SearchCondition(wt.part.WTPart.class, wt.vc.Versioned.VERSION_IDENTIFIER+"."+wt.vc.VersionIdentifier.VERSIONID,wt.query.SearchCondition.EQUAL,partRevision));

Re: Need to pass the number, iteration and the version of my document to a query. But I'm not getting to version.

Hi, Yogesh.

Thanks!

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum! ______________________________ Check out the Windchill Tips Board! We're talking about Whirlpool's use of digital twin, augmented reality, and data-driven design!

The NAVIGATE WORKING GROUP is here! Come innovate with PTC!

Sign up for a Working Group