Calculated Value script unable to update attribute value, when attribute is untouched.
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.
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
One other answer
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.
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
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.
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.