Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
Dear Experts,
I am trying to rename a WT part name using Import from spreadsheet functionality even though I receive a message stating that validation is succeeded, I dont see the change in the name of the Part
Can some one suggest a way to fix this
Currently I am using WC 10.1, M040
Thanks,
Athmanand
Solved! Go to Solution.
I don't think import from spreadsheet or loadfromfile could help in renaming wtparts. You could modify structure by adding or renaming components. You can write a custom utility to do that. By the way what does your methodserver log file say?
Thanks
Binesh
Barry Wehmiller
I don't think import from spreadsheet or loadfromfile could help in renaming wtparts. You could modify structure by adding or renaming components. You can write a custom utility to do that. By the way what does your methodserver log file say?
Thanks
Binesh
Barry Wehmiller
Hello Binesh,
Thanks for the clarification
Completely forgot about method server , Let me check it
Thanks,
Athmanand
Athmanand,
if you want to write custom utility then below are some sample API which u need to use
public static void renameWTPart(String[] array) {
// Read csv file to get the original number, new number and name,
String orgNumber = array[1];
String oldName = array[2];
String newNumber = array[3];
String newName = array[4];
WTPartMaster partMaster = null;
WTPartMaster dupMaster = null;
String message;
try {
// Search for existing part
partMaster = (WTPartMaster) getWTPartMaster(orgNumber);
if (partMaster == null) {
message = "ERROR: Can not find WTPart: " + orgNumber;
addToLogs(message, logFile);
// If we always return true then the load will continue
return;
}
//search for with new WTPart number incase if part already exist
dupMaster = (WTPartMaster) getWTPartMaster(newNumber);
if (dupMaster != null) {
message = "ERROR: WTPart already exists in database: " + newNumber;
addToLogs(message, logFile);
// If we always return true then the load will continue
return;
}
try {
// change WTPart identiry i.e. rename
WTPartMasterIdentity partIdentity = (WTPartMasterIdentity) partMaster.getIdentificationObject();
orgNumber = partIdentity.getNumber();
partIdentity.setNumber(newNumber);
partIdentity.setName(newName);
IdentityHelper.service.changeIdentity(partMaster, partIdentity);
PersistenceHelper.manager.refresh(partMaster);
message = "SUCCESS: Renamed successfully: " + orgNumber + " to " + newNumber;
addToLogs(message, logFile);
}// try
catch (WTException ex) {
message = "FAIL: Rename error: " + orgNumber + " to " + newNumber + ": " + ex;
addToLogs(message, logFile);
// If we always return true then the load will continue
return;
}
}// try
catch (Exception ex) {
message = "FAIL: Rename error: " + orgNumber + " to " + newNumber + ": " + ex;
addToLogs(message, logFile);
}// catch
}
public static WTPartMaster getWTPartMaster(String orgNumber) {
WTPartMaster wtPartMaster = null;
QuerySpec qs = null;
try {
qs = new QuerySpec(WTPartMaster.class);
SearchCondition sc1 = new SearchCondition(WTPartMaster.class, "number", "=", orgNumber);
qs.appendWhere(sc1);
QueryResult qr = PersistenceHelper.manager.find(qs);
if (qr.size() > 0) {
wtPartMaster = (WTPartMaster) qr.nextElement()
} catch (WTException ex) {
ex.printStackTrace();
}
return wtPartMaster;
}
Hope it helps !!!
Thanks
Shreyas
I have a utility that can mass rename WTParts in Windchill. It can do either name, number, or both. It is run from a WC shell and the input is a simple CSV file.
If you're looking to do a large mass rename, let me know if you're interested and we may be able to work something out.
Hi
Is there any OOTB rename utility for mass rename for WTPart?
If not pls share your utility
Thanks
Afroz
I believe the import from spreadsheet will rename objects but also iterates them.
I don't want to iterate them I think any OOTB utility would be update attribute without iteration
Dear Shreyas,
Thanks for sharing the details,
@ Bob is your utility similar to the one shared by Shreyas
Thanks,
Athmanand
It's a bit simpler in terms of the setup, but yes the concept is the same.
@ Binesh,
You are right,
Column Header | Required | Editable on reimport | Description |
---|---|---|---|
Action | Yes | Actions include Add or Delete. | |
Type | Yes | No, class type cannot be changed for existing parts | Class type, logical identifier, or an external type ID. For example:
Note The class types can be defined in the logical identifiers file with an alias. For example, wt.part.WTPART=part. Part, Manufacturer Part and Vendor part will be included in the logical id file. |
Name | Yes | No, part name cannot be changed for existing parts | Part name. |
Thanks Anand for confirmation.