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

We are happy to announce the new Windchill Customization board! Learn more.

Rename WTDocument Primary Content File

CorySkradski
1-Newbie

Rename WTDocument Primary Content File

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

1 REPLY 1


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

Top Tags