How do I querry if fields are NULL or not set?
I am using the restful web interface into a 4.0 version of RTC. I can do many queries for specific =, <, or > but I am unable to find a way to search for NULL values. I would like to get results for when a workitem does not have a resolutionDate, or if it does have a resolutionDate so that I could get reports of all resolved or unresolved work items.
This same unresolved question appears at http://www.ibm.com/developerworks/forums/thread.jspa?threadID=467391&start=15&tstart=0. |
3 answers
The only way to do this, that I can see, is either:
state/id=open state1id or state/id=open state2id
OR
state/id!=closedState1id and state/id!=closedState2id
So this is stinky. But don't worry, it gets stinkier!
If you need your application to be dynamic to support a variety of projects with a variety of states... or don't want to worry about maintaining the list of open or closed state ids... then you can programatically get the state ids of the states in the closed group, like so:
1) Query the project area for work item type ids (using OSLC):
/ccm/oslc/types/_ProjectAreaId
2) Iteratively query each of the work item shapes for work items you're interested in to find the workflow IDs:
/ccm/oslc/contexts/_ProjectAreaId/shapes/workitems/workItemId (from step 1)
Note: This query requires OSLC version 2.0, so you must set a header: "OSLC-Core-Version: 2.0"
3) Iteratively query the workflow IDs found in step 2 to determine available states, and state groups:
/ccm/oslc/workflows/_ProjectAreaId/states/workFlowId (from step 2).
It sure would be nice if there was an easier way. Normally I would never resurrect an old post... but I had this question and could not see another answer in the forum... so had to go and painfully figure this out.
|
Is there a valid answer to this question? I'm tasked with the same issue, trying to create a REST based query where the field / entry is null.
Comments
Donald Mason
commented Oct 27 '14, 3:19 p.m.
I wish there was, I was never able to figure it out.
Donald Nong
commented Oct 28 '14, 5:30 a.m.
In OSLC specification, there is no mentioning about testing null value in the query capability, so I doubt that any product implementing OSLC will have such capability.
|
Hi Donald,
Some attributes have an "Unassigned" option: Resolution date doesn't have that option. However, if you're simply looking for a list of unresolved or resolved work items, the Status can be queried for Unresolved or Resolved: Comments
Donald Mason
commented Mar 07 '13, 9:12 a.m.
Thank you for answering, but I am not looking for how to do this via the gui options. I am looking for how to query this with the rest interface.
Hi Donald,
Donald Mason
commented Mar 07 '13, 12:38 p.m.
He Lauren, that example shows some language (java maybe), but I am not sure how to translate that back to the REST web query. Also, it is a workaround of getting a value by keying off another value. It does not answer how to do the general query of how to find NULL or NOT NULL. I will be writing many different queries and would need to check for NULL on any field.
|
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.