Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Script Based Calculated Value firing order

Hi,

I have 3 fields: A, B, C and in addition I wrote 2 scripts for Calculated Values.
B sets its value according to what's written in A  - should run 1st.
C sets its value according to what's written in B - should run 2nd.

Those 2 scripts run each time my work item is saved.

How can I set the firing order of the scripts, so I can check the value of B after it gets changed. If the 2nd script will run prior to the 1st script I will get wrong behaviour.

Thanks,
Amit.

0 votes



6 answers

Permanent link
Hi Amit,

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.

0 votes


Permanent link

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.

0 votes


Permanent link
Feel free to submit enhancement requests.

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.

0 votes


Permanent link
We have a calculated values script that sets a number of default fields and this works fine except when certain changes are made to the WI. It appears that the script is firing all the time and not on a change of a values on a specific field. for example the priority field value is set and the WI saved, when we then change the priority value and save although it shows the new value -  when refreshing the WI it still show the old value. We think it is firing the script again and not because the new value was not saved
We basiciall only want the script to fire on a attribute value change on a specific field and not on open/save/refresh

0 votes

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.


Permanent link
Hello Patrick - I sit next to John Lander (above) - what we had expected from an attribute using a calculated script, was that it would only fire when the attribute upon which it depended, changed. However when revisiting the documentation [https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Calculated_values] it states:
  • 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.
Doom!

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.

0 votes


Permanent link
Sorry, ..  Ralph .. not Patrick ..

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 6,122

Question asked: Jun 21 '12, 8:06 a.m.

Question was seen: 5,634 times

Last updated: Sep 25 '12, 10:03 a.m.

Confirmation Cancel Confirm