Have an issue with Calculated scripts
Hi,
2 answers
Some hints.
- Get the work item state into a variable.
- Return the owner when the work item type is not PCR
Comments
Thanks Ralph. I did tidy it up quite a bit. However, the previous state is always returning blank though the the previous state atttribute has a value. The previous state attribute is set using another calculated script. Can you tell me if this is possible at all.
Looking into my Chrystal Ball..... Comes up with nothing. You basically don't provide the information needed. If workItem.getValue("CalcState") is always null, then the code that is supposed to set it to the attribute "CalcState" is interesting and not the code that reads it. Also which attribute type you use to store the value. I would suggest to debug that calculated value first to make sure that works.
Ralph, the calculated state is working fine and is being set as shown below. Only the getvalue is returning empty...!MESSAGE LOG: 'Calc State : '
The attribute type is small string and yes I am using the id. Below is the code...
That code uses a different ID, if that ID is now the correct one, I assume your prevstate returns a value other than null. I also would suggest, again, to use Chrome and to debug your script.
Thanks for all the help Ralph! I got this working by using a different logic. One last question. The custom attributes are hidden on the editor presentation for all states and on creation. The changes to these attributes are showing up in the history. Is there any way to suppress these entries?
Suresh, you are changing a real attribute as a work around to be able to detect a state change. There is no way to configure an exception for one attribute to not participate in the audit history. So, no, you can't. A way that does not contaminate the work item history that much would be using a follow up action. In general I am not such a fan of automated ownership. You could basically have a query and/or a report that the IT Manager uses to see the items they should pick up.
Thanks Ralph! Yes it is some people in my current client who are asking for these kind of requirements.
As a consultant, it would be possible to point out when things should not be done and why. 8) But I know that there are those who don't want to listen and then also complain later when things start breaking.