Set RTC status/resolution together (Java API)
I need to set the status/resolution of work items. I'm currently doing this the following way:
1) WorkItemWorkingCopy.saveWorkflowAction(String) to set the status
2) WorkItemWorkingCopy.save(IProgressMonitor) to save the status
3) IWorkItem.setResolution2(Identifier<IResolution>) to set the resolution
4) WorkItemWorkingCopy.save(IProgressMonitor)
However, this does not work correctly since the resolution depends on the status.
For example: using the RTC GUI, I can select the correct status, and then the valid resolutions appear on the resolution drop-down. If I save the work item, the resolutions then disappear from the drop-down and only the selected one is there. So when using the above API methods, the work item is being saved with no resolution set, which makes it go to the default. The resolution setting is therefore not recognised and fails (with no error message - simply nothing happens). I cannot set the resolution before saving the status because then RTC does not recognise the selected status.
Using IWorkItem.setState2(Identifier<IState>) works, but is deprecated. What is the current solution for this?
1) WorkItemWorkingCopy.saveWorkflowAction(String) to set the status
2) WorkItemWorkingCopy.save(IProgressMonitor) to save the status
3) IWorkItem.setResolution2(Identifier<IResolution>) to set the resolution
4) WorkItemWorkingCopy.save(IProgressMonitor)
However, this does not work correctly since the resolution depends on the status.
For example: using the RTC GUI, I can select the correct status, and then the valid resolutions appear on the resolution drop-down. If I save the work item, the resolutions then disappear from the drop-down and only the selected one is there. So when using the above API methods, the work item is being saved with no resolution set, which makes it go to the default. The resolution setting is therefore not recognised and fails (with no error message - simply nothing happens). I cannot set the resolution before saving the status because then RTC does not recognise the selected status.
Using IWorkItem.setState2(Identifier<IState>) works, but is deprecated. What is the current solution for this?
Accepted answer
don't you want to use WorkFlowInfo.getResolutionIds(action)?
as the state hasn't changed yet, cause the save hasn't completed.
so you would want to get the potential resolutions for that action.
then u would use the getWorkitem() to be able to set the resolution.. (hm.. should be available thru the workingcopy, but you never know)
-
getResolutionIds
Identifier<IResolution>[] getResolutionIds(Identifier<IWorkflowAction> actionId)
- Parameters:
-
actionId- - Returns:
- all resolutions available for the given action
as the state hasn't changed yet, cause the save hasn't completed.
so you would want to get the potential resolutions for that action.
then u would use the getWorkitem() to be able to set the resolution.. (hm.. should be available thru the workingcopy, but you never know)
One other answer
Alexander,
looking at the way the internal tests of the RTC SDK do it, it would appear that this could work:
Identifier<IWorkflowAction> actionID ... ;
Identifier<IResolution> resolution ... ;
workingCopy.setWorkflowAction(actionId.getStringIdentifier());
WorkItem workItem= (WorkItem) workingCopy.getWorkItem();
workItem.setResolution2(resolution);
status= workingCopy.save(null);
Does this work for you? If this answers your question, please mark it as accepted.
Best,
Arne
looking at the way the internal tests of the RTC SDK do it, it would appear that this could work:
Identifier<IWorkflowAction> actionID ... ;
Identifier<IResolution> resolution ... ;
workingCopy.setWorkflowAction(actionId.getStringIdentifier());
WorkItem workItem= (WorkItem) workingCopy.getWorkItem();
workItem.setResolution2(resolution);
status= workingCopy.save(null);
Does this work for you? If this answers your question, please mark it as accepted.
Best,
Arne