Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How can I determine if a work item attribute has changed

I am trying to write a javascript to set (return) the value of an attribute if the attribute it depends on has changed.  It is not important to know the value of the primary attribute, just that it changed.

I am trying to use a script based "calculated Value".  The script gets invoked when the primary attribute changes, but it also gets invoked every time the work item is saved.  This is problematic because I do not have the situation where the value of one attribute depends on the value of another attribute.  The dependency is a changed value.

The real-life goal.  There is an attribute on the work item that indicates a particular action has taken place (e.g. passed or failed system test).  I am trying to set a date stamp on another field that indicates when the primary field changed.  The value of the primary attribute (passed, failed, in progress, etc.) is not important in this context.  What is important is to know when the transition took place.

From the users perspective this information is desired on the editor next to the primary attribute.  This is not something the users want to go look up in the history.

Thanks
John Hetrick

1

0 votes


Accepted answer

Permanent link
The only way you can detect that a specific attribute has been changed - from my experience at least - is having a calculated value provider that has only one dependency to the attribute to monitor. There are no other ways in JavaScript I would be aware of to tell you what attribute changed or what the original value was. See https://jazz.net/library/article/1093 Lab 5 for examples.

John Hetrick selected this answer as the correct answer

1 vote

Comments

I have very similar problem. I need to know if field was changed or not.

there is no reliable way in JavaScript. The prior state is not passed like in the java advisor.


One other answer

Permanent link
Hi John,
               The whole script will get triggered on the workitem save operation.

But, you can choose to set the timestamp value - after checking whether the particular attribute has been modified or not. If its not modified, you can set a default null value to the attribute - something like if/else.

I guess its a plugin that you are trying to configure. how is the trigger point defined?

Thanks.

0 votes

Comments

Valli,
No plugin-in, just a javascript applied to a script based Calculated Value.

I have not been able to find a way to determine if a value has been changed or not.  If I could that would solve my problem. Nor have I found a way to determine if the event is a modify or a save event.  As you indicated both will run the script.

I would take any suggestions or a javascript code snippet if you have it.
Thanks
John Hetrick

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,944

Question asked: Dec 03 '12, 6:33 p.m.

Question was seen: 5,805 times

Last updated: Feb 18 '14, 5:55 a.m.

Confirmation Cancel Confirm