Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

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.

0 votes


Accepted answer

Permanent link

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

0 votes

Comments
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


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. 

Thank you Ralph, I will protect my code from any incoming data.
Thanks again!

Yusuke

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,954

Question asked: Aug 04 '22, 5:16 a.m.

Question was seen: 566 times

Last updated: Aug 07 '22, 10:37 p.m.

Confirmation Cancel Confirm