Re: Changing States of workitems programatically
Hi All,
I am implementing a custom participant plugin. Based on certain conditions, i need to change the state of the workitem. I am using the setstate2() function, but not sure how to get the value of the Identifier <IState> for all the available states in the workflow. Thanks. |
10 answers
the IWorkflowInfo object has methods to get all the IDs and their text names.
the IWorkflowInfo can be located off the operation data
|
Hi All, setState2 will not work. You have to use IWorkItemServer.saveWorkItem2 method. Best regards, Michele. |
Hello.
My code looks like this: IWorkItem sourceworkItem = (IWorkItem) auditable; IProjectAreaHandle projectArea = sourceworkItem.getProjectArea(); IItemHandle item = sourceworkItem.getItemHandle(); IAuditableCommon iac = ((ISaveParameter) data).getSaveOperationParameter().getAuditableCommon(); Integer Id = sourceworkItem.getId(); String parentWItype = sourceworkItem.getWorkItemType(); IWorkItemServer workItemServer = this.getService(IWorkItemServer.class); IStatus a1 = workItemServer.saveWorkItem(sourceworkItem, "Close"); I am getting a stale state error. I tried using the workingcopy, but unable to find the save method. |
you don't SAVE WITH the workingCopy class.. you GET a workingCopy (read/write) of the workitem (read only)..
then you save THAT with the saveWorkItem2() method |
Hi Sam,
I get the below errors after including "com.ibm.team.workitem.client" dependency in manifest file: 2012-05-28 15:38:58,168 ERROR eam.repository.provision.internal.ProvisionService - CRJAZ0291I Failed to start the bundle "advisor.example 1.0.0.201205281530". org.osgi.framework.BundleException: The bundle could not be resolved. Reason: Missing Constraint: Require-Bundle: com.ibm.team.workitem.client; bundle-version="3.0.2" at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolverError(AbstractBundle.java:1313) at org.eclipse.osgi.framework.internal.core.AbstractBundle.getResolutionFailureException(AbstractBundle.java:1297) at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:309) at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:280) at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:272) at com.ibm.team.repository.provision.internal.ProvisionService.startFeatureBundles(ProvisionService.java:1341) at com.ibm.team.repository.provision.internal.ProvisionService.installFromProfiles(ProvisionService.java:1049) at com.ibm.team.repository.provision.internal.ProvisionService.installFromProfileNoWait(ProvisionService.java:1146) at com.ibm.team.repository.provision.internal.ProvisionService.installFromProfile(ProvisionService.java:1084) at com.ibm.team.repository.provision.internal.ProvisionService.installFromContextConfigurationUrl(ProvisionService.java:1163) at com.ibm.team.repository.web.internal.Activator$1.run(Activator.java:125) at java.lang.Thread.run(Thread.java:811) * The component is available in the target platform path though (SDK). Thanks. |
see my response in your other post.
net you can't use '.client' classes on the 'server'. '.client' is for Eclipse or standalone application side. |
Thanks Sam. This is the brief of my code:
IWorkItemServer service = getService(IWorkItemServer.class); IWorkItem a = service.findWorkItemById(145, IWorkItem.FULL_PROFILE, monitor); for (IAttributeHandle ia:a.getCustomAttributes()) { IAttribute attribute= iac.resolveAuditable(ia,IAttribute.FULL_PROFILE, monitor); a.setValue(attribute, finalexp); IStatus st1 = service.saveWorkItem2(a, null, null); I am getting assertion failed error at the setvalue method of the attribute. I read that we need to get a working copy of the item. My plugin is a server-side plugin and i couldnt find any options to setvalue or save work item using a working copy. How can this be done? Thanks. |
you cannot save the read only copy of the workitem..
you must get & modify and save the workingcopy // reference the right object type (cast) IWorkItem workItem = (IWorkItem) auditable; IWorkItem rr = (IWorkItem)workItem.getWorkingCopy(); |
Thanks Sam. I figured it out and it works now.
|
Thanks Sam. I figured it out and it works now. Wonderful! |
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.