It's all about the answers!

Ask a question

Create workItem programaticaly with mandatory fields set


kavita herur (5876894) | asked Feb 13 '13, 7:41 a.m.

 Hi

 currently I am using workitems.createAndLink from IworkItem to create and link to parent work ticket.

 Now I want to make few attributes mandatory at first save( like uninitialed --> new state).

Is there method while create I can pass mandatory field values and then link that to parent work ticket.

I made few attributes mandatory by -- Operational behavior-->Save Work Item(server)--preconditions--> required properties.

because of these mandatory fields  child is not gettig created.

 I have set up RTC local server. In RTC -SDK I checked IworkItem class but I didnt find any method.

 Please can any  one suggest me.

 Thanks,

Kavita

 

One answer



permanent link
Ralph Schoon (63.5k33646) | answered Feb 13 '13, 8:35 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Feb 13 '13, 8:36 a.m.
Kavita,

I am unable to find a IWorkItem.createAndLink() method in the API.

If you follow https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation and you are on the client you can use a WorkitemOperation to create (and modify) a work item. This is the best way I am aware of.

If you have required attributes you will have to pass the values to the operation and set the work item attribute values before you leave the operation which triggers the save.

With respect to the sate. setState2() is deprecated in 4.x. You are supposed to trigger a workflow action. As far as I can tell, you have to save for every action. The initial save will bring the work item into the new state.

You can find many hints and solutions to your questions above on http://rsjazz.wordpress.com/ and in the forums - you can search the forums either using its built in search or using a search engine.


Comments
kavita herur commented Feb 14 '13, 8:18 a.m.

Thanks,Ralph

I am trying in process configuration code changes in enctment section.  How do I check the other methods  like createWorkItem() and what parameters should be passed. Is it RTC Plain Java client library need to be set in  RTC eclipse client?


Ralph Schoon commented Feb 14 '13, 8:41 a.m. | edited Feb 14 '13, 8:42 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

I am not sure I understand your question.  You can download the JavaDoc for the plain Java Client libraries. You can use the Plain Java Client Libraries in Eclipse as well. The best way to set this up is

  1. Setup Eclipse with the SDK as described in https://jazz.net/library/article/1000
  2. Create A User Library, name it PlainJavaAPI, and add the Plain Java API jar's
  3. For your plain Java program, create a Plugin Project. add the client plugins to the dependencies and add the User Library to the build path

Now you have the best of both worlds, you can use the PDE and Java search to search the API, code completion works and you can still run or debug it using a main method in Eclipse.

I think I explained a bit in https://jazz.net/library/article/807

I shall blog about it. Unfortunately I have not time now.


kavita herur commented Feb 17 '13, 7:31 a.m. | edited Feb 17 '13, 7:31 a.m.

Thanks, Ralph

 I have RTC SDK and PlainJava API set up in eclise.

Actualy in process configuration source code in <enactment > section I have script that generates child WT.Earlier its CreaAnd LInk method is called and then assigning title and other values to child WT.

 When I make few fields mandatory on first save. child is not getting created.I guess may be because  createAndLink failing.

Is ther way /method I can pass mandatory field values, work item type, to create WTand then link to parent? This has to be in process configuration source code.

This is what I have currently.

if(childWT== null ){
  childWT= workitems.createAndLink(successorWorkflowElement, WorkItemEndPoints.PARENT_WORK_ITEM, currentWorkItem).getWorkingCopy();
  childWT.setHTMLSummary(com.ibm.team.foundation.common.text.XMLString.createFromPlainText("child WT - " + currentWorkItem.getHTMLSummary().getPlainText()));

 Thanks,

Kavita


Ralph Schoon commented Feb 18 '13, 3:52 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

Kavita,

I can only repeat, I can not find a method createAndLink() anywhere in the SDK. Neither in https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation. Anyway, if you create your own method to create a work item, you have to pass the required attribute values and set the attribute values before you save the work item.

Your answer


Register or 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.