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

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

More OIR Customization

Darrell
13-Aquamarine

More OIR Customization

I recently ran into a problem when trying to use an attribute (attribute1) value for the number using OIR code like this:

<!-- set the number to attribute1 value plus a generated number -->
<AttrValue id="number" algorithm="com.ptc.windchill.enterprise.revisionControlled.server.impl.NumberGenerator">
  <Attr id="attribute1"/>
  <Arg>{GEN:wt.enterprise.SequenceGenerator:WTDOCUMENTID_seq:7:0</Arg>
</AttrValue>

 

The NumberGenerator algorithm concatenates the numbers together, but using the value of attribute1 seems to be a problem when using an enumeration constraint with the attribute. Even though the value of attribute1 might be a number in the UI, the internal name of the enumeration is added before the attribute value when used in the OIR. For example, the value of attribute might be 15, but <Attr id="attribute1"/> in the OIR above returns attribute1_enum_15, where attribute1_enum is the internal name of the enumeration.

 

This is unexpected behavior, but after much trial and error, I figured out how to strip off the internal name in the OIR using wt.rule.algorithm.Substring.

<!-- set the number to attribute1 value plus a generated number -->
<AttrValue id="number" algorithm="com.ptc.windchill.enterprise.revisionControlled.server.impl.NumberGenerator">
  <!-- Required because the value for attribute1 returned here is the enum's internal name plus underscore plus enum's value. This substring algorithm strips off the internal name returning only the enum's value. -->
  <Value algorithm="wt.rule.algorithm.Substring">
    <Attr id="attribute1"/>
    <Arg>16</Arg>
  </Value>
  <Arg>{GEN:wt.enterprise.SequenceGenerator:WTDOCUMENTID_seq:7:0}</Arg>
</AttrValue>

 

In the OIR code, 16 is the length of the internal name of the enumeration plus an underscore. Since internal names don't change, I think it's safe to use this hard-coded number of characters. This might not be the best logic to use in the OIR, but it works.

0 REPLIES 0
Announcements

Top Tags