Can we programmatically create work item/s using work item templates in RTC?
RTC SDK APIs provide automation in creating and updating work items. RTC also supports work item templates to create work item/s using UI based on template configured in RTC. Is there support for creating work item/s based on work item templates using RTC SDK APIs? If yes, then can someone please provide a head start?
Thanks.
Thanks.
2 answers
Thanks Ralph for help and Rahul for asking question!
I found this code working to create workitems using templates.
Method call "instantiateTemplate" basically creates WI using process templates
IWorkItemTemplateClient witc = (IWorkItemTemplateClient) repository.getClientLibrary(IWorkItemTemplateClient.class);
String projectAreaName = "Project name;
IProcessClientService processClient = (IProcessClientService) repository
.getClientLibrary(IProcessClientService.class);
URI uri = URI.create(projectAreaName .replaceAll(" ", "%20"));
IProjectArea projectAreaHandle = (IProjectArea) processClient.findProcessArea(uri, null, null);
System.out.println(projectAreaHandle.getName());
List<IWorkItemTemplateHandle> templateHandles = witc.getTemplateHandles(projectAreaHandle, monitor);
for(IWorkItemTemplateHandle templateHandle : templateHandles){
if(templateHandle.getName().equals("Epic Template")){
System.out.println("Name===="+templateHandle.getName());
Map<IAttributeVariable, Object> map = new HashMap<IAttributeVariable, Object>();
int[] count = witc.instantiateTemplate(templateHandle, map, monitor);
}
}
I found this code working to create workitems using templates.
Method call "instantiateTemplate" basically creates WI using process templates
IWorkItemTemplateClient witc = (IWorkItemTemplateClient) repository.getClientLibrary(IWorkItemTemplateClient.class);
String projectAreaName = "Project name;
IProcessClientService processClient = (IProcessClientService) repository
.getClientLibrary(IProcessClientService.class);
URI uri = URI.create(projectAreaName .replaceAll(" ", "%20"));
IProjectArea projectAreaHandle = (IProjectArea) processClient.findProcessArea(uri, null, null);
System.out.println(projectAreaHandle.getName());
List<IWorkItemTemplateHandle> templateHandles = witc.getTemplateHandles(projectAreaHandle, monitor);
for(IWorkItemTemplateHandle templateHandle : templateHandles){
if(templateHandle.getName().equals("Epic Template")){
System.out.println("Name===="+templateHandle.getName());
Map<IAttributeVariable, Object> map = new HashMap<IAttributeVariable, Object>();
int[] count = witc.instantiateTemplate(templateHandle, map, monitor);
}
}