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

Is there any Direct API to get latest version/ Iteration of object based on View .

@_1647
13-Aquamarine

Is there any Direct API to get latest version/ Iteration of object based on View .

Reference topic - https://community.ptc.com/t5/Windchill/Report-to-list-WTParts-of-particular-view/m-p/96770#M11366

Hi @Marco_Tosin

 

I have WTPart on 3.4 with design View 

And I have created a new view for the same object and that is on 0.1 Custom View .

 

So is there any Direct API to get latest version/ Iteration of object based on View .

 

 

2 REPLIES 2
HelesicPetr
22-Sapphire I
(To:@_1647)

Hi @_1647 

generally no. There is no direct api to get latest design view.

I usually use a querySpec to get latest versions and then return the last Design one. 

String partNumber = "searchdNumber";
WTPart searchedDesignPart = null;
try
{
	QuerySpec queryspec;
	queryspec = new QuerySpec();
	int idWTPartObject = queryspec.appendClassList(WTPart.class, true);
	CompositeWhereExpression andCondition = new CompositeWhereExpression(LogicalOperator.AND);
	andCondition.append(new SearchCondition(WTPart.class, WTPart.LATEST_ITERATION, SearchCondition.IS_TRUE), new int[]{idWTPartObject});
	andCondition.append(new SearchCondition(WTPart.class, WTPart.NUMBER, SearchCondition.LIKE, partNumber), new int[]{idWTPartObject});
	queryspec.appendWhere(andCondition, new int[]{idWTPartObject, idWTPartObject});
	queryspec.appendOrderBy(new OrderBy(new ClassAttribute(WTPart.class, WTPart.MODIFY_TIMESTAMP), false), new int[]{0});

	QueryResult resPart = PersistenceHelper.manager.find((StatementSpec) queryspec);

	while (resPart.hasMoreElements())
	{
		Object obj[] = (Object[]) resPart.nextElement();
		WTPart part = (WTPart) obj[0];
		if (part.getViewName().equalsIgnoreCase("Design"))
		{
			searchedDesignPart = part;
		}
	}
} catch (WTException e)
{
	e.printStackTrace();
}

PetrH

@_1647
13-Aquamarine
(To:HelesicPetr)

Hi HelesicPetr,

Thank you for help.

Actually I want to get latest iteration of  each view of same object.

 

Announcements

Top Tags