It's all about the answers!

Ask a question

Building a query for work item(s) in closed state group


r vijay (3676) | asked Aug 30 '10, 3:49 a.m.
Hi
I have to build a query to get collection of work item(s) in closed state group.
i tried the following but it didn't work.

IQueryableAttribute statusAttr = factory.findAttribute(projectArea, IWorkItem.STATE_PROPERTY, auditableServer, null);
expr.add(new AttributeExpression(statusAttr, AttributeOperation.EQUALS, IWorkflowInfo.CLOSED_STATES ));

please let me know how to iterate thru the closed state group to find all work item in closed state group.

thanks
Vijay.

2 answers



permanent link
SEC Servizi (97123660) | answered Oct 22 '13, 3:30 a.m.
Instead of:
expr.add(new AttributeExpression(statusAttr, AttributeOperation.EQUALS, IWorkflowInfo.CLOSED_STATES ));
	
you have to use:
expr.add(new VariableAttributeExpression(statusAttr, AttributeOperation.EQUALS, new StatusVariable(IWorkflowInfo.CLOSED_STATES));
		
Cheers.

permanent link
Noel Gimeno (1521417) | answered Mar 26 '13, 12:09 p.m.
Hi Vijay.
State gruops does not seem to be part of work item profile, but there is a class you may use in order to get this property for querying (that is SyntheticAttributeIdentifiers):

>Get the state group as a querable "attribute":
IQueryableAttribute stateGroupQuerable = factory.findAttribute(projectArea, SyntheticAttributeIdentifiers.STATE_GROUP_PROPERTY, auditableCommon, monitor);

>Create your attribute Expression:
AttributeExpression(stateGroupQuerable , AttributeOperation.OPERATOR_STG_EQUALS, value);
-Where argument "value" is an object implementing IStateGroup interface, not a "String" nor a "int" you can directly get from IWorkflowInfo.
Take a look to IWorkflowManager to figure out how to get the IStateGroup value, either by a known work item state or directly by the state group id.

>Run your query!

Hope it helps. Any comment welcome..



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.