Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X
Hello,
I would like to retrieve the constraints of a classification attribute (Valid Range, Legal Value List, String Values, etc).
I tried it like mentioned in https://www.ptc.com/en/support/article/CS240966
PersistableAdapter persistableAdapter = new PersistableAdapter(manuPart, null, SessionHelper.manager.getLocale(),new DisplayOperationIdentifier());
AttributeTypeSummary attrDesc = persistableAdapter.getAttributeDescriptor(internalAttrName);
attrDesc.getLegalValueSet();
attrDesc.getConstraints();
getLegalValueSet() always returns null, even though all attributes I tried have at least 1 constraint.
getConstraints() is deprecated and also returns null.
I tried so many different approaches, nothing worked. I found another post from last year, where the same problem was described.
Is there another way to query attribute constraints, is there some kind of service for that?
Thanks and best regards
Solved! Go to Solution.
Hi , would you try below approach
TypeDefinitionReadView clfNodeView = TypeDefinitionServiceHelper.service.getTypeDefView(AttributeTemplateFlavor.LWCSTRUCT,
"com.ptc.csm.default_clf_namespace", "<Classification Node Internal Name>");
AttributeDefinitionReadView adrv = clfNodeView.getAttributeByName("<Classification Attribute Internal Name> ");
Collection<ConstraintDefinitionReadView> constraints = adrv.getAllConstraints();
System.out.println("constraints======>"+constraints);
Hi , would you try below approach
TypeDefinitionReadView clfNodeView = TypeDefinitionServiceHelper.service.getTypeDefView(AttributeTemplateFlavor.LWCSTRUCT,
"com.ptc.csm.default_clf_namespace", "<Classification Node Internal Name>");
AttributeDefinitionReadView adrv = clfNodeView.getAttributeByName("<Classification Attribute Internal Name> ");
Collection<ConstraintDefinitionReadView> constraints = adrv.getAllConstraints();
System.out.println("constraints======>"+constraints);