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

Is it possible to automatically call a Java function each time when an object is edited?

TS_10782016
4-Participant

Is it possible to automatically call a Java function each time when an object is edited?

Hi, I just added a new property called "price" to WTPart. I want to know that, when adding children to a parent WTPart, are there ways to calculate and update the total price of a parent WTPart automatically, by adding the prices of its children WTPart together? 

 

For example, A is the final product, B ($5) and C ($10) are children of A. First I create A, leave the price blank. Then I add C to A as a child, I would like to see the "price" property of A automatically updated to $10. Then add B to A as a child, the price of A is updated to $15.

 

I'm using Windchill 12.1, just wondering if it's possible. I'm new to customization of windchill but have some experiences in Java programming, so if yes, could you please also tell me what are the steps I should do? 

 

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
avillanueva
22-Sapphire II
(To:TS_10782016)

Another option is a listener which can pick up on check in events for Parts. It can do whatever you want. I have a few running. They are well documented in the customers guide.

View solution in original post

4 REPLIES 4
TDT
12-Amethyst
12-Amethyst
(To:TS_10782016)

Hi @TS_10782016,

 

Write a datautility on price attribute of parent part.

Add a logic to traverse the part structure, calculate the price value of all child parts and return the total value.

In the below article you will find how to resgiter the data utlity.

https://www.ptc.com/en/support/article/CS368786?source=search

Also, There is a attribute called calculated attribute.

The above use case should also be able to acheive from calculated attribute.

avillanueva
22-Sapphire II
(To:TS_10782016)

This sounds like a case for a calculated attribute:

https://www.ptc.com/en/support/article/CS361192?source=search

Maybe a customization is needed. I am not sure of when its invoke but the scenario you are describing is that the parent attribute can keep changing without the parent object being iterated. 

avillanueva
22-Sapphire II
(To:TS_10782016)

Another option is a listener which can pick up on check in events for Parts. It can do whatever you want. I have a few running. They are well documented in the customers guide.

Hi Avillanueva,

I just finished the customization using listener and it works well! Thank you

Top Tags