Warning during WorkItem link deletion
2 answers
Angelo,
I would write a follow-up action on work item save that does the following:
- retrieve all links that have been deleted during the current action;
- if this deleted links set is not null, send an alert.
List<IReference> removedReferences = new ArrayList<IReference>();
IWorkItemReferences refs = saveParameter.getNewReferences();
removedReferences = refs.getDeletedReferences(endPointDescriptor);
I have no ready-to-use examples, instead, for point 2.
Comments
Luca,
thanks for your response but my request is a little different.
I don't want a notification during the save but a warning when I delete a link. Is it possible?
Bye.
Angelo,
I would define a check attribute on the work item, basically a flag, that must be checked to enable links deletion.
An advisor should read this attribute on work item save and return a validation error if it is not flagged and a link has been deleted.
In order for the "warning" mechanism to work, this attribute should be unflagged every time a new action on the work item begins, or simply after a positive check (that is, first you check whether the attribute is flagged; if it is not, return an error; if it is, unflag the attribute and let the action complete without errors).
Sorry, a follow-up action, rather than an advisor, would better perform this check.
Follow up action are not what should be used to prevent saving in such a case. A pre-condition or advisor should be used.
The design with the flag does not seem to be a good one. Way too complex and annoying. You will also have all the attribute changes in the work item history.
I don't know if there is a good way to implement this.
Regardless of the considerations about the complexity of the solution, perhaps the only way to implement it is to develop both an advisor (to perform the check), and a participant (follow-up action) to unflag the attribute after any action.
I have not been able to come up with a better solution.
In the Eclipse client there is a feature to override some of theĀ advisors. I am not sure if that is available in the web UI.
Another thought was to use additional save parameter to communicate but I have not found a real scenario either.