It's all about the answers!

Ask a question

Attachement is back from "saveParameter.getNewState()" when Work Item attribute "Filed Against" set Teamarea.


Yusuke Hara (1) | asked Aug 04 '22, 5:16 a.m.
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


permanent link
Ralph Schoon (63.5k33646) | answered Aug 04 '22, 6:52 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Aug 04 '22, 7:09 a.m.

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>
Ralph Schoon selected this answer as the correct answer

Comments
Yusuke Hara commented Aug 05 '22, 1:34 a.m.
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



Ralph Schoon commented Aug 05 '22, 2:02 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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. 


Yusuke Hara commented Aug 07 '22, 10:37 p.m.
Thank you Ralph, I will protect my code from any incoming data.
Thanks again!

Yusuke

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.