RTC Calculated Value triggering for any change in status or attribute
I have a script which should update a counter based on changes in owner field. I put the counterstring having dependency on Owned By. Following is the script:
dojo.provide("counterString");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes"); (function() { dojo.declare("counterString", null, { getValue: function(attribute, workItem, configuration) { try { var counter = parseFloat(workItem.getValue("counterstring")); console.log("Count String is 1: " + counter + "\n\n"); if (isNaN(counter)=== true) { console.log("Count String now is 2: " + counter + "\n\n"); counter = 0 ; console.log("Count String now is: 3" + counter + "\n\n"); } else { console.log("Count String now is 4: " + counter + "\n\n"); counter = counter + 1; console.log("Count String now is 5: " + counter + "\n\n"); console.log("Exiting Counter String"); } return counter.toString(); } catch(err) { var txt; txt="There was an error on this page.\n\n"; txt+="Error description: " + err.message + "\n\n"; txt+="Click OK to continue.\n\n"; console.log("Inside ERR Counter String" + txt + "\n\n"); } } }); })();
This script executes every time the State or any attribute is changed. I only want script to execute when the Owned By is changed. As of now when Owned By is changed, the script executes twice, one for Owned By Change and second for the save.
|
2 answers
Per document https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Script_based_calculated_values
the script will be executed in 3 cases:
Comments
Ankit Shah
commented Jul 23 '15, 12:26 a.m.
Lily
Thanks for the answer. Can you shed light on how i can check if the owner is changed?
|
Ralph Schoon (63.5k●3●36●46)
| answered Jul 23 '15, 4:34 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
This is very hard to do. An approach you could try is:
Another approach would be to not use JavaScript but a Java based follow up action. In a follow up action you have the old state of the work item and the new state and you can compare them and then issue a second save to increase the counter. See https://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/ for an example. This extension would have to be deployed on the server and configured as operational behavior. |
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.