Skip to main content
12-Amethyst
April 8, 2013
Solved

Windchill Customization(Giving constraint to an attribute)

  • April 8, 2013
  • 2 replies
  • 13223 views

Hi everybody !

I am very new to this forum & very beginner to windchill 10.1.

Is this possible to add constraint to an attribute through program.

(ex. SingleValuedConstraint, LegalValueList)

Best answer by KD_01

Using this code has one demerit

The OOTB processor can’t persist the value so you have to write a custom processor also.

2 replies

1-Visitor
April 8, 2013

For WC 9.1:

In my experience, manipulating the AttributeContainer of the IBAHolder and the related View objects is overly complex. That statement's probably debatable, but directly manipulating the Persistable constraints seems much easier.

Here's an example of creating a DiscreteSet constraint:

Object values[] = new Object[]{"Blue","Red","Green"};

DiscreteSet ds = new DiscreteSet(values);

WTTypeDefinition td = ....

AttributeDefinition ad = ....;

TypeSingleAttrConstraint constraint = new TypeSingleAttrConstraint();

constraint.setTypeDefinition(td);

constraint.setAttributeDefinition(AttributeDefinitionReference.newAttributeDefinitionReference((AbstractAttributeDefinition)ad));

constraint.setBindingRuleClassName(SingleAttributeConstraintBindingRule.class.getName());

constraint.setEnforcementRuleClassName(DiscreteSetConstraint.class.getName());

constraint.setEnforcementRuleData(ds);

constraint = save/insert(constraint);

You may want to clear/reset any applicable cache afterwards.

KD_0112-AmethystAuthor
12-Amethyst
April 9, 2013

Thanks Matthew.

I am in 10.1 and what I want to do is suppose there is one soft attribute of Document named "New". Now I need a dropdown box in the UI with some value like the attached picture and again that attribute will be a multi valued attribute.

So, how to do that?

I want to give the value programmatically cause those values will come from a txt file.Untitled.png

1-Visitor
November 6, 2013

Hi Kaushik,

Thanks for sharing the code. Please share the processor src too. this will help a lot.

Thanks in Advance.

17-Peridot
January 5, 2015

Hi, in 10.2 you have this OOTB, called "External Enumerated Value List". There you can pull the values from a text file or even from a DB like ERP.

wcbru_10_2_M020.png
Happy New Year!
Björn
1-Visitor
May 19, 2015

Hi Kaushik,

I have one doubt. I have one custom column. I want to publish the value of distribution target there. How can I get the value of Distribution target name or number in that column?

I mean, how can I fetch the data of Distribution target IBA there?

Thanks,

Sakil