How to update attribute value based on workflow action
Hello,
I am looking to update an attribute value of a work item on a save action, depending upon the action that the user selected when hitting save. For example, our defect work item has Retest and Reopen states/transitions, and we have date fields for both to indicate the day it was set to retest or reopened. We set them manually now, but I would like those to be read only attributes that are populated automatically on save based on the transition.
Our server admin doesn't allow Java extenstions, so I have been looking a bit at the JavaScript API for attribute customization. However, I am unable to find any way with the options given to accomplish what I'm looking for. Using a Calculated value would make the most sense, but as far as I can tell you have no knowledge of the action that was fired, only the current state. I see a getWorkflowAction() in the API but that's only accessible on Conditions, which don't look like they're really used to set attribute values.
Any advice on the best way to accomplish this?
Ryan
Accepted answer
There are several approaches I have seen. My preferred approach would be a participant. See the following posts with examples: https://rsjazz.wordpress.com/?s=participant. The paticipant can easily detect the state change and then modify the value as needed. It has all API available you could ask for and it is a proven solution.
I have seen people trying this with JavaScript - a calculated value that passes the current value and only changes it in case of a state change. The trouble is, that there is no reliable way to detect the state change. I think you can access the action selected, but that is about it.
I have seen people trying this with JavaScript - a calculated value that passes the current value and only changes it in case of a state change. The trouble is, that there is no reliable way to detect the state change. I think you can access the action selected, but that is about it.