It's all about the answers!

Ask a question

Work Item Creation from Server Side Plugin.


Muthukumar C (32712733) | asked May 29 '12, 3:29 a.m.
retagged Jun 08 '12, 9:34 a.m. by Evan Hughes (2.4k1218)
Hi,

My requirement is that when changing the Status of a Particular Work item, I want to create a new work item in another project area.

I am using JAVA and I have to develop this functionality in SERVER SIDE PLUGIN

Any ideas / sample codes will help me .

Thanks.
Muthukumar.C

Comments
Nikhil Bharti commented Nov 27 '12, 8:04 a.m.

Hey Muthu,


I've same requirement , where I need to create WI of type Task in different project area and copy summary and description fron current workItem.Could you please send me the sample code.

Thanks,
Nik 


Muthukumar C commented Nov 27 '12, 8:15 a.m.

Nik, I am not suppose to publish the code as per my company policy.
But i am sure that by reading all the previous discussion between me and sam, you can get a overview of the process.

Accepted answer


permanent link
sam detweiler (12.5k6184201) | answered May 29 '12, 8:58 a.m.
and this topic where I posted guidance too..

https://jazz.net/forums/viewtopic.php?t=25208&highlight=create+workitem
Ralph Schoon selected this answer as the correct answer

11 other answers



permanent link
Dnyanesh Markad (291525) | answered Feb 13 '13, 11:37 p.m.
Hi All,

I have created the operationParticipant by using the createworkItem2() method. But after state change of workitem It is not generating workitem automatically. Here is my code :

if (state.equals(Inprogress))
                                {
                               
                                IProcessServerService processServerService = getService(IProcessServerService.class); ;

                                IWorkItemServer workItemServer =(IWorkItemServer) getService(IWorkItemServer.class);

                                String Pa = newWorkItem.getProjectArea().toString();
                                IProjectArea projectArea = (IProjectArea)processServerService.findProcessArea(Pa, null);
                               
                                String WItype = newWorkItem.getWorkItemType();
                               
                                IWorkItemType workItemType = workItemServer.findCachedWorkItemType(projectArea, WItype);

                                IWorkItem workItem = workItemServer.createWorkItem2(workItemType);

                                // Set the Attributes of Task work item.

                                workItem.setHTMLSummary(XMLString.createFromPlainText("Automatic WI"));

                                workItem.setOwner(newWorkItem.getOwner());
                               
                                workItem.setCategory(newWorkItem.getCategory());
                               
                                workItem.setTarget(newWorkItem.getTarget());

                                workItemServer.saveWorkItem3(workItem, null, null, null);
                               
                                }

Comments
Muthukumar C commented Feb 13 '13, 11:55 p.m.

With the initial glance, the difference is that I am using SaveWorkItem2 functional. apart from that same logic as yours. Should work. 


permanent link
sam detweiler (12.5k6184201) | answered Jun 08 '12, 6:02 p.m.
great!.. thanks for the feedback

permanent link
Muthukumar C (32712733) | answered Jun 08 '12, 4:54 a.m.
Sam

After some modification here and there in the above mentioned code, Work item is creating properly with the values supplied from the java.

Thanks!!!

Comments
Dnyanesh Markad commented Feb 13 '13, 11:23 p.m.

Hi All,

I have created the operationParticipant by using the createworkItem2() method. But after state change of workitem It is not generating workitem automatically. Here is my code :


Dnyanesh Markad commented Feb 13 '13, 11:26 p.m.

if (state.equals(Inprogress))
                                {
                                
                                IProcessServerService processServerService = getService(IProcessServerService.class); ;

                                IWorkItemServer workItemServer =(IWorkItemServer) getService(IWorkItemServer.class);

                               


Dnyanesh Markad commented Feb 13 '13, 11:26 p.m.

String Pa = newWorkItem.getProjectArea().toString();
                                IProjectArea projectArea = (IProjectArea)processServerService.findProcessArea(Pa, null);
                                
                                String WItype = newWorkItem.getWorkItemType();
                                
                              
                               


Dnyanesh Markad commented Feb 13 '13, 11:27 p.m.

IWorkItemType workItemType = workItemServer.findCachedWorkItemType(projectArea, WItype);

                                IWorkItem workItem = workItemServer.createWorkItem2(workItemType);

                                // Set the Attributes of Task work item.

                                workItem.setHTMLSummary(XMLString.createFromPlainText("Automatic WI"));


Dnyanesh Markad commented Feb 13 '13, 11:28 p.m.

workItem.setOwner(newWorkItem.getOwner());                               
                                workItem.setCategory(newWorkItem.getCategory());           
                                workItem.setTarget(newWorkItem.getTarget());

                                workItemServer.saveWorkItem3(workItem, null, null, null);
                                
                                }


Dnyanesh Markad commented Feb 14 '13, 1:41 a.m.

Is it necessary to insert ui part for creation...or the create work item() itself creates the workitem automatically in the repository?


Thanks,
Dnyanesh


Muthukumar C commented Feb 14 '13, 5:15 a.m.

No need for UI part. You have to use the CreateWorkItem method to create work item. Pass the values for that work item and calling the SaveWrokItem2 method is only required. 

showing 5 of 7 show 2 more comments

permanent link
Muthukumar C (32712733) | answered May 30 '12, 9:13 a.m.
Thanks Sam.

I almost completed the Work Item creation. Once I deployed the plugin, Will give you the feedback tomorrow.



here is how to find the category choices.. (all found by looking at the Javadoc)

IWorkItemCommon.findCategories(IProjectAreaHandle, ItemProfile, org.eclipse.core.runtime.IProgressMonitor)

to get the target iteration, you need to find them.. starting at project

IDevelopmentLineHandle getProjectDevelopmentLine()
then u can get the iterations from the development line
IIterationHandle[] getIterations()
then u can analyze the iterations and decide which one to pick

Sam

permanent link
sam detweiler (12.5k6184201) | answered May 30 '12, 9:07 a.m.
here is how to find the category choices.. (all found by looking at the Javadoc)

IWorkItemCommon.findCategories(IProjectAreaHandle, ItemProfile, org.eclipse.core.runtime.IProgressMonitor)

to get the target iteration, you need to find them.. starting at project

IDevelopmentLineHandle getProjectDevelopmentLine()
then u can get the iterations from the development line
IIterationHandle[] getIterations()
then u can analyze the iterations and decide which one to pick

Sam

permanent link
Ralph Schoon (59.7k23643) | answered May 30 '12, 7:26 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
The Link ProgrammaticWorkItemCreation I sent before shows how to set the Categories. For Planned for you need to find the iteration.

permanent link
Muthukumar C (32712733) | answered May 30 '12, 1:20 a.m.
Hi,

When using the createWorkItem2 method, I have to assign the value for all mandatory fields before saving the work item.

But every time I am getting struck when assigning the values to fileds like Category and Planned For.

How to pass the values to this fields using workItem.setTarget and workItem.setCategory methods.

Now my total code look some thing like this

// TEST Creation of WorkItem

IProcessServerService processServerService = getService(IProcessServerService.class); ;
IWorkItemServer workItemServer = getService(IWorkItemServer.class);
IProjectArea projectArea = (IProjectArea)processServerService.findProcessArea("TAM Regression", null);
IWorkItemType workItemType = workItemServer.findCachedWorkItemType(projectArea, "Task");
IWorkItem workItem = workItemServer.createWorkItem2(workItemType);
// Set the Attributes of Task work item.
workItem.setHTMLSummary(SourceWI.getHTMLSummary());
ICategoryHandle FiledAgainst = ????;
workItem.setTarget(????);
workItem.setCategory(????);
workItemServer.saveWorkItem2(workItem, null, null);


and this topic where I posted guidance too..

https://jazz.net/forums/viewtopic.php?t=25208&highlight=create+workitem

		                                        

permanent link
Ralph Schoon (59.7k23643) | answered May 29 '12, 8:42 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
A quick search lead to

getService(IWorkItemServer.class).createWorkItem2(workItemType);

There are several references to createWorkItem2 in the SDK, that you could look at to understand how to use it.

permanent link
Ralph Schoon (59.7k23643) | answered May 29 '12, 8:19 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Please look at "WorkItemOperation" and try if you can run that in the server in a precondition/followup action.
I have not created a work item in the server yet and thus I don't have other example code, but I would try this code.

Your answer


Register or to post your answer.