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

The community will undergo maintenance on October 16th at 10:00 PM PDT and will be unavailable for up to one hour.

Rename a WT part using Import from Spreadhseet

Anand
1-Newbie

Rename a WT part using Import from Spreadhseet

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

ACCEPTED SOLUTION

Accepted Solutions
BineshKumar1
12-Amethyst
(To:Anand)

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

View solution in original post

11 REPLIES 11
BineshKumar1
12-Amethyst
(To:Anand)

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

satre-2
1-Newbie
(To:Anand)

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

bsindelar
6-Contributor
(To:Anand)

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

avillanueva
22-Sapphire II
(To:AA_9841156)

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 

Anand
1-Newbie
(To:Anand)

Dear Shreyas,

Thanks for sharing the details,

@ Bob is your utility similar to the one shared by Shreyas

Thanks,

Athmanand

bsindelar
6-Contributor
(To:Anand)

It's a bit simpler in terms of the setup, but yes the concept is the same.

Anand
1-Newbie
(To:Anand)

@ 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:

  • for OEM parts, use wt.part.WTPart
  • for manufacturer parts, use com.ptc.windchill.suma.part.ManufacturerPart
  • for vendor parts, use com.ptc.windchill.suma.part.VendorPart

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.

BineshKumar1
12-Amethyst
(To:Anand)

Thanks Anand for confirmation.

Announcements


Top Tags