It's all about the answers!

Ask a question

Action result states do not match workflow states


Anthony Krowiak (11111612) | asked May 18 '09, 12:35 p.m.
I am trying to programmatically determine which workflow action to execute in order to transition workflow state for a defect. I use the following methods to accomplish this task:

IWorkItem.getState2() - to get the id of the current state
IWorkflowInfo.getAllStateIds() - to find the id of target state
IWorkflowInfo.getActionIds(Identifier<IState>) - to get valid actions in the current state
getActionResultState(Identifier<IWorkflowAction>) - to get the result state id for each action.

The problem is, the state id from getActionResultState does not match any of the state ids from getAllStateIds, so I am unable to determine the required action.

In fact, none of the action result state ids match any of the state ids from the getAllStateIds method.

Is this a bug, or is there another way to accomplish this task?

5 answers



permanent link
Patrick Streule (4.9k21) | answered May 18 '09, 2:08 p.m.
JAZZ DEVELOPER
I am trying to programmatically determine which workflow action to
execute in order to transition workflow state for a defect. I use
the following methods to accomplish this task:

IWorkItem.getState2() - to get the id of the current state
IWorkflowInfo.getAllStateIds() - to find the id of target state
IWorkflowInfo.getActionIds(Identifier<IState>) - to get valid
actions in the current state
getActionResultState(Identifier<IWorkflowAction>) - to get the
result state id for each action.

The problem is, the state id from
getActionResultState does not match any
of the state ids from getAllStateIds, so
I am unable to determine the required action.

In fact, none of the action result state ids match any of the state
ids from the getAllStateIds method.

Is this a bug, or is there another way to accomplish this task?

Could you paste a snippet of code that illustrates the calls in context?
What you describe sounds basically ok, and maybe we can spot the problem.

--
Regards,
Patrick
Jazz Work Item Team

permanent link
Anthony Krowiak (11111612) | answered May 19 '09, 3:39 p.m.
I am trying to programmatically determine which workflow action to
execute in order to transition workflow state for a defect. I use
the following methods to accomplish this task:

IWorkItem.getState2() - to get the id of the current state
IWorkflowInfo.getAllStateIds() - to find the id of target state
IWorkflowInfo.getActionIds(Identifier<IState>) - to get valid
actions in the current state
getActionResultState(Identifier<IWorkflowAction>) - to get the
result state id for each action.

The problem is, the state id from
getActionResultState does not match any
of the state ids from getAllStateIds, so
I am unable to determine the required action.

In fact, none of the action result state ids match any of the state
ids from the getAllStateIds method.

Is this a bug, or is there another way to accomplish this task?

Could you paste a snippet of code that illustrates the calls in context?
What you describe sounds basically ok, and maybe we can spot the problem.

--
Regards,
Patrick
Jazz Work Item Team

The silly method below illustrates the problem, it will ALWAYS return null:

public Identifier<IWorkflowAction> getAction( IWorkItem workItem,

IWorkflowInfo workflowInfo )
{
Identifier<IWorkflowAction> findActionId = null;
Identifier<IState>[] allStates = workflowInfo.getAllStateIds();
Identifier<IState> curState = workItem.getState2();

for (Identifier<IState> stateId : allStates)
{
Identifier<IWorkflowAction>[] allActions = workflowInfo
.getActionIds( curState );

for (Identifier<IWorkflowAction> actionId : allActions)
{
Identifier<IState> resultState = workflowInfo
.getActionResultState( actionId );

if (resultState.equals( stateId ))
{
findActionId = actionId;
}
}
}

return findActionId;
}

permanent link
Patrick Streule (4.9k21) | answered May 24 '09, 6:48 a.m.
JAZZ DEVELOPER
The silly method below illustrates the problem, it will
ALWAYS return null:
public Identifier<IWorkflowAction
getAction( IWorkItem workItem,
IWorkflowInfo workflowInfo )
{

I can't see anything obvious in the code. When you print out the states,
is there a pattern why they don't match? Originally, states were integers
and later changed to strings. There is come compatibility code that
transforms identifier like 's2' back to '2'. So If some of the states that
are compared have the identifiers 's1, s2, s3' and others '1, 2, 3', this
would explain why they never match.

--
Regards,
Patrick
Jazz Work Item Team

permanent link
Patrick Streule (4.9k21) | answered May 24 '09, 6:56 a.m.
JAZZ DEVELOPER
I can't see anything obvious in the code. When you print out the states, is there a pattern why they don't match? Originally, states were integers and later changed to strings. There is come compatibility code that transforms identifier like 's2' back to '2'. So If some of the states that are compared have the identifiers 's1, s2, s3' and others '1, 2, 3', this would explain why they never match.

--
Regards,
Patrick
Jazz Work Item Team

permanent link
Anthony Krowiak (11111612) | answered May 26 '09, 1:22 p.m.
I can't see anything obvious in the code. When you print out the states, is there a pattern why they don't match? Originally, states were integers and later changed to strings. There is come compatibility code that transforms identifier like 's2' back to '2'. So If some of the states that are compared have the identifiers 's1, s2, s3' and others '1, 2, 3', this would explain why they never match.

--
Regards,
Patrick
Jazz Work Item Team


That is exactly what appears to be happening, the action result states have identifiers that begin with the 's' character. What is this compatibility code of which you speak?

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.