It's all about the answers!

Ask a question

Calculated Value script unable to update attribute value, when attribute is untouched.


Johan Carlström (285) | asked Nov 12 '15, 4:40 a.m.
I have a problem with the Calculated Value script setting value to an attribute. The problem is that the script does not change the value of the attribute when saving/changing a Work Item IF the attribute has not been written in (manually) before.
   It does however get the updated values if the whole page is refreshed but it does not get any new values after that. If I just write an empty space in the attribute field then the script starts working and updating the values correctly.

I have tested changing the attribute types to an enumeration instead of text but the same problem remains.

The goal of the script is to notice when a Work Item leaves a specific state, in this case a field needs to be cleared. So the script is saving the "previous state" when a Work Item changes states, and another script clears the field if the previous state is one of the chosen triggers. 

If there is any way to solve the original problem or a way to complete the goal in another way I would be very grateful!

Thanks in advance.

Accepted answer


permanent link
Johan Carlström (285) | answered Nov 16 '15, 2:50 a.m.
edited Nov 16 '15, 2:50 a.m.
This is now solved.

The problem was that the Work Items where not synched. I had to perform a mass synchronization on all of the affected Work Items but then it worked as indended!
Ralph Schoon selected this answer as the correct answer

One other answer



permanent link
Ralph Schoon (61.5k33643) | answered Nov 12 '15, 4:54 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
See https://jazz.net/wiki/bin/view/Main/AttributeCustomization for when scripts are supposed to be triggered. That happens for example if, in the UI, a dependent attribute changes.
The scripts can not detect a state changes. The Action is only available in conditions, so you would need at least one calculated, hidden, attribute to store the last state to be able to detect the new state.

Comments
Johan Carlström commented Nov 12 '15, 5:16 a.m. | edited Nov 12 '15, 5:24 a.m.

I have checked that link and there is not a problem with the triggering since 

"When a work item is saved, the script is executed to recalculate the value."

I have a two hidden fields, calculating the previous state when a Work Item is saved. These scripts work if I create a new Work Item. They do not work on previously created Work Items unless I write something in the fields manually once. After that they start responding to the scripts.

It seems that the fields are not registered in some way until they are changed.

Your answer


Register or to post your answer.