How to set new value to "Filed Against" attribute.
3 answers
Please consider to search the development WiKi, especially the SDK. Here is some example code https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation
I think there is no example for modifying a work item. You could look that up in the SDK itself. This code has worked for me:
The filed against is
I think there is no example for modifying a work item. You could look that up in the SDK itself. This code has worked for me:
ITeamRepository teamRepository = TeamPlatform
.getTeamRepositoryService().getTeamRepository(repositoryURI);
teamRepository.registerLoginHandler(new LoginHandler(userId, password));
teamRepository.login(null);
IWorkItemClient workItemClient = (IWorkItemClient) teamRepository
.getClientLibrary(IWorkItemClient.class);
URI uri = URI.create(projectAreaName.replaceAll(" ", "%20"));
IProjectArea projectArea = (IProjectArea) processClient
.findProcessArea(uri, null, null);
if (projectArea == null) {
System.out.println("Project area not found.");
return false;
}
int id = new Integer(idString).intValue();
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(summary));
IDetailedStatus s = wc.save(null);
if (!s.isOK()) {
throw new TeamRepositoryException("Error saving work item",
s.getException());
}
} finally {
wcm.disconnect(workItem);
}
The filed against is
ICategoryHandle category = workItemClient.findCategoryByNamePath(
projectArea, path, null);
wc.getWorkItem().setCategory(category )
Hi,
Thanks for your reply. My code looks like this. I tried getting existin category value.
import com.ibm.team.repository.client.IItemManager;
import com.ibm.team.repository.client.ITeamRepository;
IItemManager itm = teamRepository.itemManager();
//get existing category value.
ICategory category = (ICategory) itm.fetchCompleteItem(parentWorkItem.getCategory(), IItemManager.DEFAULT, monitor);
System.out.println("This is category: " + category.getName());
when I use above import statements, the plugin itself is not deployed on the server. It is giving this message
State
CopyAttributeValuesToChildWI (Operation Advisor) completed successfully.
what could be the probelm.
And I neednot change complete category list to new list of values, but I need to change the selected value against Filed Against field before saving workitem.
Please suggest me on this issue.
Regards,
Radhika
Thanks for your reply. My code looks like this. I tried getting existin category value.
import com.ibm.team.repository.client.IItemManager;
import com.ibm.team.repository.client.ITeamRepository;
IItemManager itm = teamRepository.itemManager();
//get existing category value.
ICategory category = (ICategory) itm.fetchCompleteItem(parentWorkItem.getCategory(), IItemManager.DEFAULT, monitor);
System.out.println("This is category: " + category.getName());
when I use above import statements, the plugin itself is not deployed on the server. It is giving this message
State
CopyAttributeValuesToChildWI (Operation Advisor) completed successfully.
what could be the probelm.
And I neednot change complete category list to new list of values, but I need to change the selected value against Filed Against field before saving workitem.
Please suggest me on this issue.
Regards,
Radhika
Hi Ralph,
To work with ITeamRepository, IWorkItemClient I have imported respective packages
import com.ibm.team.workitem.client.IWorkItemClient;
import com.ibm.team.repository.client.ITeamRepository;
and added corresponding pulg-ins in Dependencies tab plug-in.xml.
If I add these plug-ins in Dependencies tab, the advisor plug-in is not deployed into server. These two packages are related to client.
I have checked windows->preferences->plug-in development->Target platform's Target Definition It has all the plug-ins listed there.
What is the procedure I need to follow.
Thanks in Advance,
Radhika Bandari
To work with ITeamRepository, IWorkItemClient I have imported respective packages
import com.ibm.team.workitem.client.IWorkItemClient;
import com.ibm.team.repository.client.ITeamRepository;
and added corresponding pulg-ins in Dependencies tab plug-in.xml.
If I add these plug-ins in Dependencies tab, the advisor plug-in is not deployed into server. These two packages are related to client.
I have checked windows->preferences->plug-in development->Target platform's Target Definition It has all the plug-ins listed there.
What is the procedure I need to follow.
Thanks in Advance,
Radhika Bandari