Attribute customization - How to prioritize calling the calculated script before Operation behavior on save
2 answers
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
Hi Lily,
Thanks for your reply. You are correct, script is executed only on those conditions.
but my situation is : Due to operational behavior, the "LinkCounter" attribute is becoming mandatory field on "set done" state, And am getting the error message : "Attribute LinkCounter should be set".
Note : LinkCounter value can be set only by script(script calculates the total links present) and not manual entry of value.
Now am linking one WI to the current WI so that, count becomes 1. and when I save the WI, Save is not allowed, due to the error message : "attribute LinkCounter is not set".
But value of "LinkCounter" can be populated only on save of the WI, as its value is populated from the script.(i.e, When WI is saved, number of links is now updated to 1 in RTC) and the value will populate to the attribute.
So Is there any way, I can prioritize on save then on Operation behavior "required on types and attributes".
Thanks in advance.
The problem is when you add a link to the current WI, the calculated value provider script will not be triggered so it still remains as "0". Then when you try to save the WI, the pre-condition fails.
1 vote
Really really thanks for your reply Lily.
Yes I completely agree to your point that, the script is not called when the link is added and it still remains "0".
As Donald suggested, I have the follow-up action set up.
The following scenario is perfectly working fine,it is my basic scenario(User will add the link, before "set done" state). That adding a link, calling the follow-up script to update the link count and change the status to "Set done". It is populating the correct link counts.
But my scenario is the reverse : (In short : User should not be allowed to set the WI to "set Done" state, when there is no links present for the WI) :
1. User selects the "set done" state.
2. Gets the error message : "Attribute LinkCounter not set" [ as am making this value mandate - in operation behavior on set done state]. LinkCounter internally has the scripts that count the link value.
3. User links the some WI to current WI.
4. On click of save, RTC is not allowing to save the links attached and script is not called, being value not updated and finally error message not going.
5. It is expecting value to the "LinkCounter" field, that I cant enter manually, which need to be populated from the script.
Is there any way, first saving and then calling the operation behavior(that overrides it)
I look forward for your suggestions and comments.
Really really thanks for your reply Lily.
Yes I completely agree to your point that, the script is not called when the link is added and it still remains "0".
As Donald suggested, I have the follow-up action set up.
The following scenario is perfectly working fine,it is my basic scenario(User will add the link, before "set done" state). That adding a link, calling the follow-up script to update the link count and change the status to "Set done". It is populating the correct link counts.
But my scenario is the reverse : (In short : User should not be allowed to set the WI to "set Done" state, when there is no links present for the WI) :
Really really thanks for your reply Lily.
Yes I completely agree to your point that, the script is not called when the link is added and it still remains "0".
As Donald suggested, I have the follow-up action set up.
The following scenario is perfectly working fine,it is my basic scenario(User will add the link, before "set done" state). That adding a link, calling the follow-up script to update the link count and change the status to "Set done". It is populating the correct link counts.
But my scenario is the reverse : (In short : User should not be allowed to set the WI to "set Done" state, when there is no links present for the WI) :
- User selects the "set done" state.
- Gets the error message : "Attribute LinkCounter not set" [ as am making this value mandate - in operation behavior on set done state]. LinkCounter internally has the scripts that count the link value.
3. User links the some WI to current WI.
4. On click of save, RTC is not allowing to save the links attached and script is not called, being value not updated and finally error message not going.
5. It is expecting value to the "LinkCounter" field, that I cant enter manually, which need to be populated from the script.
Is there any way, first saving and then calling the operation behavior(that overrides it)
I look forward for your suggestions and comments.
You cannot expect a detailed implementation from the forum. Have you added the attribute "LinkCounter" in the WI editor, as hidden? If it's not there, I'm not sure the calculated value script will ever run.
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_.
Comments
Hello Donald,
Thanks for your reply, I would like to add my contents to the issues you have mentioned.
1. Attribute"LinkCounter" not set - I agree for your comment, that there will be no links present when a WI is created, However, I have declared the WI as Integer, and the value zero is present in the beginning.
Attribute is not set only when
saving the value to the attribute as it is mandatory field now and its value cant be set manually. It has to be only through script.
2. You may have to develop a follow-up participant in the source work item to change the "LinkCounter" value directly, say +1.
Could you please help me with more details on the follow-up participant as to what it is ? am not sure about it.
The source for this is RTC itself.
I look forward for your comments and suggestions.