How to retrieve workitem changes and attribute modifications?
I have written a code to fetch the attribute values from a workitem - triggered on the save operation (Operation Participant Plugin). I want to distinguish if it's a new/modify/delete operation - plus the changes that are made during each of the save operation - like the old and new values of a particular attribute and so on. How can this be achieved programatically?
Thanks.
3 answers
Below code snippet will solve your query
Object data = operation.getOperationData();
if(data instanceof ISaveParameter){
ISaveParameter saveparameter = (ISaveParameter)data;
IAuditable WIOldState = saveparameter.getOldState();
IAuditable WINewState = saveparameter.getNewState();
..........
...........
...........
In this code, WIOldState will have the Old values of the work item attributes and WINewState will have the values during the save.
Of course, if WIOldState== null, then it means Creation of NEW Work Item.
Hope its usefull.
Regards
Muthukumar.C
Comments
Hi Muthukumar,
I cant see any point in capturing the Delete operation. What ever the code you are writing in the Plugin will be executed during the SAVE operation. (Modification / Creation)
In which scenario you want to capture the delete operation.??
Hi,
the scenario is such that we are updating 1 parent record - which is of another WI Type based on updations made in WI Items of another category. So, when a WI is deleted, i will have to restore the values in the parent record to deduct the contents of the deleted record. Its more of calculation based
Thanks.
Sorry valli, I am totally out of loop now.
Actually you are having a Plug-in that will execute when saving a work item. (Create / Modify)
In the plug-in code itself, you will delete another work item or what? I am not sure whether I am reading you correctly.
Else, Are you asking for - your code should execute during the deletion of WI manually???
Better to post some code from your plug-in so that I can see the workflow of the Plug-in and where your requirement is hidden
I have a plugin that executes on WI-Save operation and its an Operation Participant. Once a record is created, i use the values to update another WI record (different WI Type). So, i want to execute a part of the code in the same plugin - during deletion of WI - to redo the changes made. How to capture the WI delete operation?
Thanks.
After a long, I hope, I got a solution for your requirement....
Hope you remember that we will mention Plugin Action as WorkItemSave during the creation of Plug-in.
Same way, you can create a plugin which will execute during the Delete operation of WIs. You can add this plugin in the preconditions of the Delete Work Item [Server]
Regards
Muthukumar.C