It's all about the answers!

Ask a question

Precondition on workitemDelete

Paulo Cavoto (1111) | asked May 11 '12, 1:49 p.m.

I am coding a precondition to prevent the user to delete workitems that are on a specific state or have some specific attributes filled.
I managed to create the precondition and debug it, the problem is I couldn't get the workitem being deleted, the AdvisableOperation that use to have this information inside the operationData, now returns null, using that property I was able to get the SaveParameter and the Workitem been saved, when running on the SaveWorkItem

How can get the workItem being deleted ?

Paulo Cavoto

Luana Santos commented Apr 17 '13, 1:52 p.m.

 Paulo, did you have an answer to your question?

I am trying to create an advisor to validate the workItem before deletion.

Thanks in advance,

Paulo Cavoto commented Apr 17 '13, 9:33 p.m.

Hi Luana,

At least on version 3.x, there is no  information on the data object, the code should work fine, the problem is in RTC delete operation. Are you using version 4, maybe they have fixed it 

Luana Santos commented Apr 22 '13, 6:25 p.m.

 Paulo, yes, I'm using version 4. But the data object is still null, and I could not find a solution for that.

Have you found an alternative for your problem?

2 answers

permanent link
sam detweiler (12.5k6195201) | answered May 11 '12, 10:00 p.m.
here is my advisor code

public void run(AdvisableOperation operation, IProcessConfigurationElement advisorConfiguration, IAdvisorInfoCollector collector, IProgressMonitor monitor) throws TeamRepositoryException {
if(Debug) System.out.println("in operation advisor");
// get the operation data
Object data= operation.getOperationData();

// is this a 'save' operation?
if (data instanceof ISaveParameter)
// get the affected object
IAuditable auditable = ((ISaveParameter) data).getNewState();

// if this is a workitem
if (auditable instanceof IWorkItem)
// reference the right object type (cast)
IWorkItem workItem = (IWorkItem) auditable;

permanent link
Paulo Cavoto (1111) | answered May 14 '12, 9:19 a.m.
here is my advisor code

Object data= operation.getOperationData();

// is this a 'save' operation?
if (data instanceof ISaveParameter)

Hi Sam,

The code you wrote works perfectly on the "workitem save" behaviour, the problem is that when you are running this a precondition on a "workitem delete ". If you add your advisor to listen to the delete behaviour, operation.getOperationData() returns null, therefore all the other code won't work

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.