Script Based Calculated Value firing order
6 answers
the scripts run when you open the work item and if you edit any of the values.
I am not sure there is an order of execution you can assume. You should make sure that the dependencies to the other attributes is set in a way that once script 1 sets B, the change in B is detected. That should trigger script 2, I think.
Hi Ralph,
Thanks for the answer.
I was asking this one in addition to another topic: https://jazz.net/forum/questions/74014/count-wi-entries-to-specific-state-by-calculated-value
dealing with counting transions from specific state to specific state.
I've manage to do so by difining new attribute which holds the old state (re-calculated on each save) and by knowing old and new state I can decide whether to add +1 to another field which implements a counter.
It works but I'm not sure why the old state script is executed before the counter script.
I think my conclusions is to ask for 3 enhancements:
1. deifine the execution order of scripts to achieve the desired behaviour.
2. create a followup action for state transition.
3. create a new built-in attribute: com.ibm.team.workitem.api.common.WorkItemAttributes.PREVIOUS_STATE
I would be glad to hear your opinion.
Thanks,
Amit.
But for a short term solution, I would rather suggest to look into the RTC Extensions workshop and create a followup action to count the state changes. there is an order in the preconditions and followup actions. It is Java and you can debug them. Server extensions work for all clients. It is just way better suited for what you try to do. Scripts are supposed to be simple and you well exceed what they can provide today.
Just my opinion.
We basiciall only want the script to fire on a attribute value change on a specific field and not on open/save/refresh
Comments
As far as I can tell, it fires if there are changes to the attributes that show up in the dependent attributes list. I have played with the scripts and, so far, it makes sense how they work. You might see an issue with refreshing the representations. However, If you feel you have a defect file a defect or if you want different behavior, please open an enhancement request.
- When a work item is created, the script is executed
- When a work item is saved, the script is executed to recalculate the value.
- When an attribute which the current attribute depends on is changed, the value of the current attribute is recalculated. Depending on the presentations of the two attributes this may not work in all cases.
Do you have any suggestions how we can filter out the first two conditions upon which it fires ? i.e when a work item is created or saved? We only want it to fire when an attribute which the current attribute depends on is changed.