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

Force save WorkItemWorkingCopy ??

Can we force save WorkItemWorkingCopy? We have developed a Java code which updates WI's with attachments. However, for some requests we get following status:

ERROR: com.ibm.team.workitem.client code=2 Attribute 'Planned For' not set com.ibm.team.process.common.advice.TeamOperationCanceledException: 'Save Work Item' failed. Preconditions have not been met: The 'Planned For' attribute needs to be set (work item 677). children=[]

We imported these records using CSV importer to RTC and will not be able to the value for "Planned For"(ideal way) because it is not known and will be filled by end user. Therefore, can we do something like force save or can bypass this check??

Relevant code snippet is:

String projectAreaName = "AMT IDC Project Area";  //Give project area name

IWorkItemClient workItemClient = (IWorkItemClient) repo.getClientLibrary(IWorkItemClient.class);
IWorkItem workItem = workItemClient.findWorkItemById(ID, IWorkItem.SMALL_PROFILE, null);
IWorkItemWorkingCopyManager wcm = workItemClient.getWorkItemWorkingCopyManager();
wcm.connect(workItem, IWorkItem.FULL_PROFILE, null);
try {
WorkItemWorkingCopy wc = wcm.getWorkingCopy(workItem);
wc.getWorkItem().setHTMLSummary(XMLString.createFromPlainText("Description updated from Java"))
//----------------------------------Code to add attachment ----------------------------------
IProcessClientService processClient= (IProcessClientService) repo.getClientLibrary(IProcessClientService.class);
URI uri= URI.create(projectAreaName.replaceAll(" ", "%20"));
IProjectArea projectArea_A= (IProjectArea) processClient.findProcessArea(uri, null, null);
try {
Add_attachments.attachFile(attach_loc,wc,projectArea_A,workItemClient);
}
catch (IOException e) {
e.printStackTrace();
}

0 votes



2 answers

Permanent link
As far as I know, you cannot bypass the check (it would be a pretty poor
check, if you could . What you could do is temporarily turn off that
check in your project area (manually), run your import, and then turn
the check back on (manually).

Cheers,
Geoff

On 9/7/2011 9:23 AM, achal wrote:
Can we force save WorkItemWorkingCopy? We have developed a Java code
which updates WI's with attachments. However, for some requests we
get following status:

ERROR: com.ibm.team.workitem.client code=2 Attribute
'Planned For' not set
com.ibm.team.process.common.advice.TeamOperationCanceledException:
'Save Work Item' failed. Preconditions have not been met: The
'Planned For' attribute needs to be set (work item 677).
children=[]

We imported these records using CSV importer to RTC and will not be
able to the value for "Planned For"(ideal way) because it
is not known and will be filled by end user. Therefore, can we do
something like force save or can bypass this check??

Relevant code snippet is:

String projectAreaName = "AMT IDC Project
Area"; //Give project area name
IWorkItemClient workItemClient = (IWorkItemClient)
repo.getClientLibrary(IWorkItemClient.class);
IWorkItem workItem = workItemClient.findWorkItemById(ID,
IWorkItem.SMALL_PROFILE, null);
IWorkItemWorkingCopyManager wcm =
workItemClient.getWorkItemWorkingCopyManager();
wcm.connect(workItem, IWorkItem.FULL_PROFILE, null);
try {
WorkItemWorkingCopy wc = wcm.getWorkingCopy(workItem);


wc.getWorkItem().setHTMLSummary(XMLString.createFromPlainText("Description
updated from Java"))
//----------------------------------Code to add attachment
----------------------------------
IProcessClientService processClient=
(IProcessClientService)
repo.getClientLibrary(IProcessClientService.class);
URI uri= URI.create(projectAreaName.replaceAll("
", "%20"));
IProjectArea projectArea_A= (IProjectArea)
processClient.findProcessArea(uri, null, null);
try {
Add_attachments.attachFile(attach_loc,wc,projectArea_A,workItemClient);
}
catch (IOException e) {
e.printStackTrace();
}

0 votes


Permanent link
Thanks a lot for the reply Geoff. Right now this is seems to be the only good approach. However, we are still analyzing it's feasibility as we have many custom fields which are mandatory at one status or other.

We were thinking of a force save kind of thing because we are able to import these records by using CSV importer and importer must also have to do a save. But as you said "It would be a pretty poor check" if we are able to by pass it :).

-Regards,
Achal

As far as I know, you cannot bypass the check (it would be a pretty poor
check, if you could . What you could do is temporarily turn off that
check in your project area (manually), run your import, and then turn
the check back on (manually).

Cheers,
Geoff

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
× 10,941

Question asked: Sep 07 '11, 2:58 a.m.

Question was seen: 5,380 times

Last updated: Sep 07 '11, 2:58 a.m.

Confirmation Cancel Confirm