Attribute customization - How to prioritize calling the calculated script before Operation behavior on save
Hi All,
I need to call the calculated script before Operation behavior on save.
This is the current scenario [Was able to achieve steps 1 to 5, but not able to succeed through steps 6 and 7] : Could you please help me on this.
1. Defined an attribute say.."LinkCounter" of type integer
2. Added a calculated script that contains the Oslc URI to get the count of "links" for the current WI (It usually returns the count of number of WI linked to it...eg ...0(zero) for no links present, 1 for one link present etc)
3. On a particular state...say "Set Done" state, I have a "operation behavior" set as "required for type and attribute" for this attribute "LinkCounter".
4. Then on changing through different states, when I am about to set it to "Set Done State" It check for the LinkCounter value. Since there is no link for the current WI, It will be the default value "0 zero".
5. As the operation behavior is set, It doesn't allow me to save the WI [error message : Attribute"LinkCounter" not set ]
This is the main area to be highlighted :
6. I now link some WI to this current WI. So that count of the attribute would become 1.
7. But the calculated script is not dynamically called and 1 is not getting updated on click of save button.
I am getting the error message : Attribute"LinkCounter" not set
Is there any way, I can call the calculated script before the opeartion behavior is set on the attribute ? so that when I create links to the WI, it calls the script and value is updated and then the operation behavior is called.
Thanks in advance
2 answers
According to the document https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Calculated_values :
If you configure a Script-based calculated value, the script will be executed in three cases:
- When a work item is created, the script is executed
- When a work item is saved, the script is executed to recalculate the value.
- When an attribute which the current attribute depends on is changed, the value of the current attribute is recalculated. Depending on the presentations of the two attributes this may not work in all cases.
Comments
1 vote
showing 5 of 7
show 2 more comments
You have two issues to deal with here.
1. Attribute"LinkCounter" not set - to avoid this, you should use a "default value" provider. It is reasonable to set it to 0 as when the work item is created, usually there should be no links attached to it.
2. Automatically change "LInkCounter" value when a bi-directional link is added outside of the work item. I am pretty sure in this case the calculated value script will _not_ be called (for the target work item). You may have to develop a follow-up participant in the source work item to change the "LinkCounter" value directly, say +1. But if the source is from QM or RM, I am not aware of any means to do it automatically. Additionally, you may also need to consider the situation where a link is _removed_.
1. Attribute"LinkCounter" not set - to avoid this, you should use a "default value" provider. It is reasonable to set it to 0 as when the work item is created, usually there should be no links attached to it.
2. Automatically change "LInkCounter" value when a bi-directional link is added outside of the work item. I am pretty sure in this case the calculated value script will _not_ be called (for the target work item). You may have to develop a follow-up participant in the source work item to change the "LinkCounter" value directly, say +1. But if the source is from QM or RM, I am not aware of any means to do it automatically. Additionally, you may also need to consider the situation where a link is _removed_.