It's all about the answers!

Ask a question

Work item attribute calculation script getting triggered even when dependent field has not changed

Robert Huet (23113384) | asked Jul 21 '16, 4:57 p.m.
In the property dialog of a custom work item attribute, I can specify dependencies on other attributes so that when those attribute values change, the associated calculation script for this attribute will be triggered  by the system (at least that's what the articles claim).

In my case, my dependency is to another calculated value, and my script is getting triggered every time I save the work item, even though the dependent attribute value has not changed.

Does this dependency association only work with user-updated attributes?

The motivation for what I'm doing is to work around the problem that RTC scripts cannot determine whether a state change has occurred.  Therefore, I have created a hidden attribute to hold previous state, and I only want calculated attribute to fire when this previous state attribute changes (it also has a calculation script to update it from the new state).

Hope this make sense.  Any tips would be greatly appreciated!

Accepted answer

permanent link
Lily Wang (4.9k714) | answered Jul 22 '16, 12:55 a.m.
According to the document :

If you configure a Script-based calculated value, the script will be executed in three cases:

  • 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.
So what you observed is working as designed.
To meet your requirement, what I did is to create a hidden attribute to record the previous state. If the current state is different to the hidden previous state, the script will set a new value to the calculated attribute. Then the previous state will be updated to the same value as the current state.

Robert Huet selected this answer as the correct answer

Robert Huet commented Jul 22 '16, 11:25 a.m. | edited Jul 22 '16, 11:27 a.m.

 Thanks, Lily,  I've noticed that the calculated value script runs on the client (browser or Eclipse) when the work item is created or when a dependent attribute is changed.  However, when the work item is saved, the script runs on the server (so can't use browser's debugger or console).  Is there any way to get the script to run on the client when the work item is saved in order to facilitate debugging?

Lily Wang commented Jul 25 '16, 5:08 a.m.

For the server-side script, if you are using "console.log()", you can find the debug log from "<JazzTeamServer>/server/tomcat/work/Catalina/localhost/ccm/eclipse/workspace/.metadata/.log" if you use Tomcat. If you use WAS, it's "<WebSphere>/AppServer/profiles/<profileName>/temp/<node>/<server>/ccm_war/ccm.war/eclipse/workspace/.metadata/.log".

Your answer

Register or 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.