Skip to main content
Apr 2, 2020 6:29 PM UTC
Question

Drive Object attribute from the context in which it is created

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

8 replies

Apr 2, 2020 6:34 PM UTC

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).

 

jbaileyAuthor
Apr 2, 2020 8:01 PM UTC

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? 🙂

Apr 2, 2020 8:07 PM UTC

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.

 

Apr 7, 2020 3:14 PM UTC
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.
jbaileyAuthor
Apr 7, 2020 3:52 PM UTC

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

Apr 7, 2020 4:32 PM UTC

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