Skip to main content
jbailey
18-Opal
April 2, 2020
Question

Drive Object attribute from the context in which it is created

  • April 2, 2020
  • 2 replies
  • 4021 views

Is there a way to use an attribute that is set on the context to drive an attribute for the objects within that context when they are created?

 

Something like assigning a "code" to the product, and make the attribute for a CR/CN/PR/Variance/DR etc match that same code

2 replies

1-Visitor
April 2, 2020

Unfortunately no, unless you create your own rule algorithm.

However, you can use the context name (something like containerName) to extract a sub string (that would be your code).

 

jbailey
jbailey18-OpalAuthor
18-Opal
April 2, 2020

On the surface, it seems it seems it should be much easier than that.  Why do I find myself saying that more and more with PTC stuff? 🙂

1-Visitor
April 2, 2020

You could try to create an alias attribute, but it might not address your need as the value would change if the object is moved from a context to another.

 

18-Opal
April 7, 2020
This should be very doable.
In short, when a brand new object is created you want one of its attribute’s value to be automatically set based on the value of its Context’s (Product or Library) attribute.

If this is what you want, write a listener to listen for post store event. Then check if the object meets your criteria for being “new” and whatever else (maybe this only applies to WTParts for example) . If it is “new” set its attribute value per your spec.

What I’ve described is doable but if I’ve misunderstood maybe you could clarify a bit more.

If you need more help feel free to contact me.
jbailey
jbailey18-OpalAuthor
18-Opal
April 7, 2020

That is exactly what I am looking for!

So I have a business attribute for the Context (GRC_PROJ_CODE) value 123456.  I would like to be able to create new objects, and use that attribute to help in auto numebring.  Something like CR-123456-(5dig seq).  Any help you have on this would be appreciated

 

projcode.JPG

1-Visitor
April 7, 2020

Then this should be achieved with a Custom Rule Algorithm and not a listener.