Calculated Value that also allows for manual setting of field?
I have a Calculated Value script working when Status (state) changes to set a custom date field (Verified Date). We also want to be able to manually set this value to correctly set dates before this script existed. When I save the manually selected date in eclipse, the date returns to blank. I saw a comment in the wiki about making Calculated Values read only in the presentation, but are you actually prevented from making manual updates to fields with a script associated with them?
|
Accepted answer
Ralph Schoon (63.5k●3●36●46)
| answered May 08 '14, 5:03 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Vince,
as far as I can tell, you are not required to make the attribute read only. However, every time the calculation script affecting this attribute you have to decide if you want to overwrite it. This is often not easy to do. As described in https://jazz.net/wiki/bin/view/Main/AttributeCustomization you can return the current value or a calculated value. You would have to make a decision somehow. Please let us know if it works for you. Vince Thyng selected this answer as the correct answer
Comments
Vince Thyng
commented May 08 '14, 9:56 a.m.
Thanks Ralph. I have my Calculated value setup to only run when there is a Staus (state) change, so I was surprised to see my manual change of the my custom date get reset immediately to blank when I saved. I am not expecting my script to be running at that point.
|
One other answer
Vince,
It is easy to get a custom attribute's current value:
currentValue= workItem.getValue('attribute id');
Ex:
contactName = workItem.getValue('defect.mycustomAttribute');
But, as Ralph mentioned you have to return some value, or else the attribute's current value is erased.
I will play with exceptions to see if that works instead. Since I'm having problems with the shared HTML attr. "Summary" I would like something like this:
If type = defect then
return some-text
else
do-nothing
Comments
Vince Thyng
commented May 12 '14, 3:30 p.m.
Thank you Henrik, this actually solves the problem have! For some reason I was thinking I needed to use the fields available with workItem.getValue(WorkItemAttributes.*). In my case 'defect.testdate' did not see it, but just 'testdate' did.
Henrik Westrell
commented May 12 '14, 4:47 p.m.
To code below seems to work. Throwing an exception (to avoid taking care of get/set the Summary current value) might have side-effects, but it works so far for me in eclipse and chrome...
if ( Type == "defect" ) {
} else {
throw 0;
}
|
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.
Comments
<removed comment, it was unrelated>