Attachement is back from "saveParameter.getNewState()" when Work Item attribute "Filed Against" set Teamarea.
![](http://jazz.net/_images/myphoto/a917dbac0067ed405a118faa66ffe415.jpg)
Hi,
"saveParameter.getNewState()" return an attachment instance instead of work item instance at following condition.
- Custom plugin use " saveParameter.getNewState()" function.
- Custom plugin set in Project area's "Followup action".
- Work item attribute "Filed Against" set team area.
- Drug and Drop attachment file on work item, then error occur, can't save work item
"Filed Against" set project area, error not occurred, at drug and drop attachment file on work item.
Environment:
- EWM 7.0.2 iFix013
Thanks.
Accepted answer
![](http://jazz.net/_images/myphoto/a917dbac0067ed405a118faa66ffe415.jpg)
This came in at some point and is still there.
Use the typical mechanism such as instanceof to make sure you get what you want.
E.g. make sure that the thing is what you expect. I f not, exit. For example:
/ * First check that the operation was a 'save' and get he operation * data. / Object data = operation.getOperationData(); if (!(data instanceof ISaveParameter)) return; ISaveParameter saveParameter = (ISaveParameter) data;/* * Check that this was a save operation on a work item */ IAuditable newState = saveParameter.getNewState(); if (!(newState instanceof IWorkItem)){ /* * If not, we don't have to deal with it. */ return; }</pre>
Comments
![](http://jazz.net/_images/myphoto/a917dbac0067ed405a118faa66ffe415.jpg)
Hi Ralph,
Thank you for sample code for treating unexpected return value.
Do you know the reason why "saveParameter.getNewState()" return attachment file instance if work item attribute "Filed Against" set team area. I am wondering this behavior.
Thanks,
Yusuke
![](http://jazz.net/_images/myphoto/e5e63d5878217b64611c1df9401b7cd3.jpg)
No, I don't know the reason. I created a defect when I first observed it. I am however not sure, if the API guarantees me to get what I expect, so the better way is to protect yourself from incoming data you can not process.
![](http://jazz.net/_images/myphoto/a917dbac0067ed405a118faa66ffe415.jpg)
Thank you Ralph, I will protect my code from any incoming data.
Thanks again!
Yusuke