Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Calling Work Item Template Invocation from Code

Does anyone have a code sample that shows how I could programatically create work items from a work item template? We would like to be able to set more fields than just "Filed Against" and "Planned For."

Thanks, Gary

0 votes



3 answers

Permanent link
and why do you think you can only set those fields?

here is one of my java client code sections that creates a new workitem. this is called from a web service, passing the parameters from another system. You build a map of all the fields and values, and 'save that' with the new workitem.
(the synchrule stuff is due to the internal processing my handler provides).

 		if(!TeamPlatform.isStarted())

TeamPlatform.startup();
try {
IProgressMonitor sPm = new SysoutProgressMonitor();
if(login(sPm)!=null)
{
// get operations handle to repository



IExternalProxy proxy = getExternalProxy(getRepository(),createItem.getProblem(),true, sPm);
IExternalState externalState = InteropFactory.INSTANCE
.createExternalState();
ISyncRule sr = getInteropMgr().findSyncRule(
StringConstants.sfdcworkitem, sPm);
proxy = (IExternalProxy) proxy.getWorkingCopy();
proxy.setSyncRule(sr);

Map<String> states = new HashMap<String>();
System.out.println("processing workitem create\n");
states.put(StringConstants.CreateOnlyType, "defect");
states.put(StringConstants.CreateOnlyfiledAgainst, createItem.getProduct());
states.put(StringConstants.CreateOnlyProblemNumber, createItem.getProblem());
states.put(StringConstants.CreateOnlySummary, createItem.getSummary());
states.put(StringConstants.CreateOnlyCreatedBy, StringConstants.UserPrefix +":"+ createItem.getAuthor());
states.put(StringConstants.CreateOnlyDescription, createItem.getDescription());
java.sql.Timestamp js = new java.sql.Timestamp(java.lang.System.currentTimeMillis());
states.put(StringConstants.CreateOnlyCreationDate, js);
states.put(StringConstants.CommonLastSynch, js);

states.put(StringConstants.CommonStatus, "Initial");
states.put(StringConstants.CommonPriority, createItem.getPriority());
states.put(StringConstants.CommonSeverity, createItem.getSeverity());
states.put(StringConstants.CommonCases,CasestoList(createItem.getCases()));
states.put(StringConstants.CommonComments,CommentstoList(createItem.getComments(),true));
states.put(StringConstants.CommonAttachments,AttachmentstoList(createItem.getAttachments()));
states.put(StringConstants.CommonImpact,createItem.getImpact());
states.put(StringConstants.CommonReproduction,createItem.getHowtoreproduce());
states.put(StringConstants.CommonCircumvention,createItem.getCircumvention());

// save the updated states
externalState.setState(states);
//interop.setSynchronizationEnabled(sr, true, sPm);
// persistently
getInteropMgr().saveProxyWithState(proxy, externalState, sPm);

0 votes


Permanent link
Thanks for the reply.

I don't want to programmatically create just a work item, but several work items via an existing work item template. Right now, those are the only two "variable" fields that can be set when creating from a work item template.

Any idea on how to do this? Thanks.

Gary

0 votes


Permanent link
sorry, no.. haven't played with templates at all.

0 votes

Your answer

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

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,940

Question asked: Mar 29 '12, 5:12 p.m.

Question was seen: 5,395 times

Last updated: Mar 29 '12, 5:12 p.m.

Confirmation Cancel Confirm