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:
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();
}
2 answers
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:
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();
}
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
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