RTC Calculated value script problem with update and read-only field
![]()
Hello,
I have used a calculated value script to fill in an integer custom attribute depending on the number of certain words in the tags of the work item. Now I have two problems: 1. I have added the script after a lot work items have been already created and tagged. How can I trigger the recalculation of the attribute? Using the one hint from the forum with bulk editing the tags via the Eclipse client does not work(https://jazz.net/forum/questions/111839/how-to-recalculate-script-based-calculated-values-for-all-wi-after-changing-the-script). The value only is updated when I change the tags in the WI editor (Eclipse and Web works) directly and save the work item. I cannot go manually over all single work items for the recalculation to happen. Is there a better way? 2. I want this calculated attribute to be read only. But when I enable the checkbox "readonly" in the custom attribute definition dialog. I cannot save anymore the work item in case the calculated value changes due to the script. How can I make this attribute read only so that only the script can do changes? PS. We are using RTC 4.0.6 at the moment. Thank you for your help |
Accepted answer
6 other answers
![]()
Ralph Schoon (61.8k●3●36●43)
| answered Sep 03 '14, 3:41 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
For 2: you don't make the attribute read-only, but the presentation of the attribute. I will have to check, because I was under the impression the scripts could write into read only attributes. However I checked if the API can write read only attributes and it can't in 5.x. So I am a bit confused how you would be able to get anything into a read only attribute, if neither scripts nor the API can actually do anything with it.
For 1: I would suggest to try to change an attribute that is set as a dependency for the calculated attribute. If a dependent attribute is changed, this should trigger the script execution. This should work in the Eclipse as well as the Web UI. You could check the logs if something actually happened. See https://jazz.net/library/article/1093 lab 5 or https://jazz.net/wiki/bin/view/Main/AttributeCustomization for where to find the logs. |
![]()
Ralph Schoon (61.8k●3●36●43)
| answered Sep 03 '14, 4:44 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
An update...... I tried again.
I was able to make the attribute read only (not the presentation) and it was set with the correct value using a script. I tried that in 4.0.3 and 5.0, so it should work for you too. In 5.0 I was not able to set the the read only attribute with a Plain Java Client Libraries tool using the API - I need to investigate if that was possible in 4.x. I also tried (with 4.0.3) to synchronize attributes. In the work Item customization editor click "check attributes usages in repository". If the Eclipse client prompts to synchronize attributes, select that. The new attribute is added to all the work items that don't have it and the calculation is executed. Comments The problem with synchronize is that I can only synchronize if new attributes are added but not if I only change the setting for calculated values provider or I even only change the javascript implementation.
![]() FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
The only idea I would have is some hidden attribute, that you use as trigger dependency. The script based calculated values are not designed to detect that the script changed as far as I can tell.
Ok fine.
![]() FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Bulk editing the tags should trigger that script - if it has a dependency set to the tag attribute. If it doesn't and you have set the dependency, that would be a defect. So did you and does it? You have to add a fake tag to all however. If the value is not changing, it might not save - per design.
I had a situation a few months ago when I 've already synchronized work items with new custom attribute, then I needed to calculate something in new custom attribute.
I 've created another custom attribute integer and made it hidden, and on query results, I 've been changing it to different values, just to produce any work item changes.
Like Ralph said, make sure to query all necessary work items.
It is a bug since it does not work.
showing 5 of 6
show 1 more comments
|
![]() I am trying to do a similar thing so that I can auto increment my Change Request #s and my Defect #s Unfortunately I do not know how to script this. Do you have any suggestions my conventions are as follows. Defects - "YYYY-nnn" - where YYY is the current year Change Requests - "PROJ-CR-nnn" where PROJ is the project name |
![]()
subscribing then unsubscribing on mass seems to work for us, may be a better answer than the others provided here ;-)
|