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

How to make invalid the child work items of a parent using server api?

I had created a parent workitem and created children based on the custom attribute(ChildCount). Now if I change the childcount the remaining which are last created need to move to invalid state. I am able to Invalidate child also but it is invalidating randomly. I below is code suggest any modifications.
                                Collections.reverse(references);
                                for (IReference reference : references) {

                                    IAuditableHandle childHandle = (IWorkItemHandle) ((IItemReference) reference)
                                            .getReferencedItem();

                                    IWorkItem child = (IWorkItem) workItemServer.getAuditableCommon()
                                            .resolveAuditable(childHandle, IWorkItem.FULL_PROFILE, monitor)
                                            .getWorkingCopy();
                                    child.getWorkItemType();

                                    IWorkflowInfo workFlowInfo = workItemServer.findWorkflowInfo(child, monitor);
                                    Identifier<IState>[] availableActions = workFlowInfo.getAllStateIds();

                                    for (Identifier<IState> stateIds : availableActions) {
                                      
                                        if (workFlowInfo.getStateName(stateIds).equalsIgnoreCase(INVALID_STATE)) {
                                            child.setState2(stateIds);
                                         
                                            Set additionalParams = new HashSet();
                                            additionalParams.add("Saved111");
                                            child = (IWorkItem) child.getWorkingCopy();
                                            IStatus saveStatus = workItemServer.saveWorkItem3(child, null, null,
                                                    additionalParams);

                                        }
                                    }
                                    childCount1--;
                                    if (childCount1 == 0) {
                                        break;
                                    }

                                }

0 votes



One answer

Permanent link

You just need to order the children work items based on their ID (or creation date), did I get it right?

Your code seems good, you can get the ID this way:

String childID = child.getId();

I suggest that you write two "for" cycles, the first to retrieve the IDs and order the children, the second to actually invalidate the last n children you've previously ordered.

0 votes

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

Question asked: Feb 07 '20, 5:24 a.m.

Question was seen: 597 times

Last updated: Feb 07 '20, 6:49 a.m.

Confirmation Cancel Confirm