Skip to main content
12-Amethyst
May 6, 2015
Solved

How to change the type of existing part.

  • May 6, 2015
  • 8 replies
  • 6661 views

Hi,

I have a WTPart and is associated with an EPM Document. Now I want to change the type of Part its subtype.

How can I achieve it?

Thanks,

Best answer by BenPerry

Can you expand on the requirement? You want to do this via API like Sudeep has suggested? Or by using some type of utility? Or something else?

There are existing articles on using a command line tool. It generates some SQL code. But the SQL code it generates will change the type of all WTPart objects. You'll need to modify the SQL for only that single WTPart if you choose this method.

https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS7287

https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS52368

8 replies

1-Visitor
May 6, 2015

Hi Avinash,

You can do this using code :

TypeHelper.setType((Persistable)partObj, TypeHelper.getTypeIdentifier("internal_name"));

PersistenceServerHelper.update(partObj);

partObj = (WTPart)PersistenceHelper.manager.refresh(partObj);

Hope this helps.

Regards

Sudeep

13-Aquamarine
January 23, 2017

I've just tried Sudeep Pai's code and it seems to work perfectly. Thank you!

I plan to use it with WTParts and prefer it over the SQL tool because it gives me better control over which part to change and which not.

Has anyone experience with this solution? Any side-effects to be aware of?

(Obviously lifecycle, attributes, versioning schema have to be taken into account, that's ok.)

17-Peridot
January 23, 2017

I've been using this since long time. But you need to pay attention to two things:

- If the target type has less or different attributes set, you won't be able to remove them afterwards and you also will find them with solr. So you need to clean them before changing the type

- If you need the history you can change only the latest iteration or you also can change all iteration

BenPerry
BenPerry15-MoonstoneAnswer
15-Moonstone
May 6, 2015

Can you expand on the requirement? You want to do this via API like Sudeep has suggested? Or by using some type of utility? Or something else?

There are existing articles on using a command line tool. It generates some SQL code. But the SQL code it generates will change the type of all WTPart objects. You'll need to modify the SQL for only that single WTPart if you choose this method.

https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS7287

https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS52368

apatil-212-AmethystAuthor
12-Amethyst
May 7, 2015

Hi all,

I want to do it in UI (any OOTB functionality).

Because a user wrongly associated many of those.

Any how I given him the workaround to use edit association to remove existing part and do association again (create new part) and its working.

And old part we are deleting.

I wanted to know can we change the type ? is there any setting ? because this is common mistake and can happen to many customers.

Thanks,

BenPerry
15-Moonstone
May 7, 2015

There is not something in the UI where you can change the type of an object. It must be done through the steps outlined in the duplicate articles I listed above (direct database edit). Furthermore, additional conditions will need to be added to the SQL code to ensure you only change the type of specific objects - not all of the objects.