It's all about the answers!

Ask a question

How to update attribute value based on workflow action

Ryan Koppelman (1525) | asked Apr 15 '14, 12:35 p.m.

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?


Accepted answer

permanent link
Ralph Schoon (63.2k33646) | answered Apr 16 '14, 4:04 a.m.
There are several approaches I have seen. My preferred approach would be a participant. See the following posts with examples: 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.

Ryan Koppelman selected this answer as the correct answer

Ryan Koppelman commented Apr 16 '14, 8:14 p.m.

Thanks, it sounds like this probably is the best approach. I will see if I can work with my server admin to get an exception in deploying this customization. 

Your answer

Register or 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.