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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Custom attributes Folder via API

AK_10639313
4-Participant

Custom attributes Folder via API

Version: Windchill 13.0

 

Use Case: We want to add some custom attributes to folders that we will need to modify during in certain cases.


Description:

Hello everyone,
I wanted to know if there is a way to make it possible to modify custom attributes for folders via API cause I'm having problem with a customization since I'm able to access only to the default "Description" attribute.
Thank you in advance

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @AK_10639313 

Additional info.

Sometimes It is very useful to check the JavaDoc documentation to understand what the service can do.

HelesicPetr_1-1715328958811.png

HelesicPetr_0-1715328920273.png

PetrH

View solution in original post

7 REPLIES 7

Hi @AK_10639313 

Try the persistable adapter and PersistenceHelper

 

 

PersistableAdapter folderObj = new PersistableAdapter(persist, null, null, null);
folderObj.load("IBANAME", "name");
folderObj.set("IBANAME", "my value");
Object obj = folderObj.apply();
PersistenceHelper.manager.store(obj);

 

example also mentioned in https://www.ptc.com/en/support/article/CS149150?

 

replaced old api with new one> https://www.ptc.com/en/support/article/CS138252

 

PetrH

Sorry for the late reply and thank you a lot for sharing a possible solution,
I tried to do as you said but it didn't apply the changes on the attributes of the folder.

Hi @AK_10639313 

You need to find a reason, why the change has not been stored(saved)

PetrH

Yes I'm trying to get some intel on why it is not working, but I'm not being able to find examples on folders sadly.
From what I've been seeing the changes do apply when you modify an object in a working state. But you cannot do that to the Folder object.
Thanks again for your support,
much appraciated

Hi @AK_10639313 

Trust me it has to work 😄

Ok. If the folder exists, then you can not use the Store helper method. So use modify

With store you could see error like this>

HelesicPetr_0-1715324252936.png

Also you could find that Object obj has to be cast to Persistable type

 

btw I've tested the code now and it works. 

 

PersistableAdapter folderObj = new PersistableAdapter(fold, null, null, null);
folderObj.load("CREATESTATE");
folderObj.set("CREATESTATE", "my value");
Object obj = folderObj.apply();
PersistenceHelper.manager.modify((Persistable) obj);

 

HelesicPetr_1-1715324393101.png

I updated the iba attribute by my code.

PetrH

Hi @AK_10639313 

Additional info.

Sometimes It is very useful to check the JavaDoc documentation to understand what the service can do.

HelesicPetr_1-1715328958811.png

HelesicPetr_0-1715328920273.png

PetrH

Hello @AK_10639313

 

It looks like you have a response from a community member. If it helped you solve your question please mark the reply as the Accepted Solution. 

Of course, if you have more to share on your issue, please let the Community know so other community members can continue to help you.

Thanks,
Community Moderation Team.

Top Tags