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

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Getting attribute values

smcvr
14-Alexandrite

Getting attribute values

Hi Community,

 

I need to control some attributes in the flow, but I have controlled them, except for a few cases.
The first error is if EN_LANG attributes in WTPart are empty, it gives an error for null value.

The second error is that SURFACE_M2 attributes are defined with com.ptc.core.meta.common.FloatingPoint type, but SURFACE_M2 attributes can receive values automatically from creo, and when this value is an integer (for example 1), it gives an error in getting the value.


I tried to get the values of these attributes in the code below

 

com.ptc.core.lwc.server.PersistableAdapter obj = new com.ptc.core.lwc.server.PersistableAdapter(part,null,java.util.Locale.getDefault(),new com.ptc.core.meta.common .UpdateOperationIdentifier());
obj.load("EN_LANG","SURFACE_M2"); EN_LANG=(java.lang.String) obj.get("EN_LANG"); SURFACE_M2=(com.ptc.core.meta.common.FloatingPoint) obj.get("SURFACE_M2");

 

 

 

ACCEPTED SOLUTION

Accepted Solutions
HelesicPetr
22-Sapphire I
(To:smcvr)

Hi  @smcvr 

It is common that empty attribute is null, so you need to catch the null exception and solve it in that case. For example result = "";

 

PetrH

View solution in original post

2 REPLIES 2
HelesicPetr
22-Sapphire I
(To:smcvr)

Hi  @smcvr 

It is common that empty attribute is null, so you need to catch the null exception and solve it in that case. For example result = "";

 

PetrH

smcvr
14-Alexandrite
(To:HelesicPetr)

Hi @HelesicPetr ,

In the rest of the code, I was checking the number of characters of the value. When the value was null, he had problems checking that part. I fixed the error now,

 

thank you 🙂

Announcements

Top Tags