How to set value of field to current timestamp based on particular state?
I have 2 medium string fields "Current State" and "Date".
2 answers
How would you trigger the script? What dependency? The State? This will likely not work, since the state changes after the save so the script would not see the change, I think. If you search this forum, you will likely realize that this has been discussed many, many times already. Some users have found ways around the problem, by using a hidden "Old State" attribute. Another solution is a follow up action (Java Server Extension).
Comments
Hi Ralph, can you refer me to the logic of hidden state attribute logic/url?
You need to think about it carefully. If the NEW state is the initial state in the work flow, I don't see any way you can trigger the calculated value script, that is during the submission. If it is indeed the initial state, you should consider using a default value, and hide the attribute in the editor. Also, if the work item is modified with the same state, should the "Date" be updated? If you want to make it complicated, the follow-up participant may be your only option.
thanks for catching the "Initial state" point.
It will not work for any changes during the save operation due to the limitation of JavaScript. I was not proposing how it could work, but rather, how it may not work.