Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X
Is it feasible to reanme a WTDocument primary content file?
I have tried the following via the Windchill API, however, the file name does not change.
ContentHolder contentHolder = ContentHelper.service.getContents(wtDocument);
ContentItem item = ContentHelper.getPrimary((FormatContentHolder) contentHolder);
if (item != null && item instanceof ApplicationData)
{
((ApplicationData) item).setFileName(newPrimaryContentName);
primaryContentNameUpdates++;
}
There are InfoEngine mechanisms to delete and/or add content items, however, I did not find any such mechanisms to simply rename the file name.
Any help would be appreciated.
Cory Skradski
Problem solved. I wasn't persisting the update. So, for anyone who is interested, here is the code snippet to update a primary content file name:
QuerySpec qs = new QuerySpec(WTDocument.class);
qs.appendWhere(new SearchCondition(WTDocument.class, WTDocument.NUMBER, SearchCondition.EQUAL, yourWTDocNumber), null);
QueryResult qr = PersistenceHelper.manager.find((StatementSpec) qs);
WTDocument wtDocument = (WTDocument) qr.nextElement();
ContentHolder contentHolder = ContentHelper.service.getContents(wtDocument);
ContentItem item = ContentHelper.getPrimary((FormatContentHolder) contentHolder);
if (item != null && item instanceof ApplicationData)
{
((ApplicationData) item).setFileName("new_file_name.xls");
PersistenceHelper.manager.save((ApplicationData) item);
}
Cory Skradski