Skip to main content
14-Alexandrite
April 20, 2026
Question

Java API to unset / delete line number (value of the attribute) of a part-usage?

  • April 20, 2026
  • 2 replies
  • 24 views

Hi All,

 

some time ago I made a customization which automatically writes the values we want to the OOTB line number attribute in wtparts at check-in, using a listener.

But as it turns out, reality is always more complex than the plan you have and your users say they want...

As of now, I found no way to ‘unset’ (aka delete) an existing line number. That sounds strange, but maybe I am just not proficient enough to read and interpret the javadoc ...🙈

The use case could be coined like this: ‘set the line number attribute of part usage id-xy (which, by the way, now has the value ‘123’) to an ‘empty’ value.‘

So, right now the tool is writing the line number like this to the attribute:

long NewlineNumber = 123;
LineNumber TheNewlineNumber = new LineNumber();
TheNewlineNumber.setValue(NewlineNumber);
usagelink.setLineNumber(TheNewlineNumber);

PersistenceServerHelper.update(usagelink);

We have left the attribute with the OOTB constraints, so it should be possible to have an empty value:

This works via the user interface in the browser.

Using the API, simply writing an empty string doesn’t work, and writing null also got me to an error…

(trying to write 0 also didn’t work, although I read in the API docs properties=@GeneratedProperty(name="value",type=long.class,supportedAPI=PUBLIC,constraints=@PropertyConstraints(lowerLimit=0)))  regarding the LineNumber class.)

Did I overlook something, maybe there is even a more generic way to achieve this?

 

greetings

2 replies

18-Opal
April 22, 2026

I saw your post and so I wrote custom Java code to remove/delete line numbers.

You mentioned you have the link id so that is what I used too.

 

Before delete the structure page displays the line number 123.

 

I run the code in a Windchill shell which shows the line number has been deleted from the link.

 

Next, I refresh the structure page and we see the line number has been deleted.

Note the WTPart was NOT iterated yet the line number is deleted.

 

So, this is quite doable.

 

David

SvenR14-AlexandriteAuthor
14-Alexandrite
April 22, 2026

that’s totally interesting! 

Yes, indeed one could argue that originally that’s ‘not the use case’, but on the other hand I came to the conclusion that when doing a ‘set’ to the attribute, the customization should also be able to do an ‘unset’ just for the sake of completeness.

The realistic use case is that a user may do a check-in of data in state in-work, that will be still be worked on next day, hence he/she decides to remove the existing value because it’s not meant to be used like it is. Then my code may fail because it is not able to delete the line number value. 🙈

Is it a more complex solution you made? I am curious about being it more close to a one-liner or a big tools setup directly writing to the database?