Reputation: 11
I have User Stories , and want to track the changes in a custom field C_L3KanbanStage, for my stories in between a date.
Is this possible. The problem I am facing, is that, I am not getting expected output.
As per my understanding, this field C_L3KanbanStage, being a drop down field, I should be able to use the comparison operators, but somehow it is not working
{
"_ProjectHierarchy": XXXXX,
"ObjectID": XXXX,
"c_L3KanbanStage": {
"$lt": "Closed"
},
"_ValidFrom": {
"$gte": "2014-03-03",
"$lt": "2014-04-15"
}
}
It should give me all lesser values then "Closed", but it gives me only one value.
However, if I try:
{
"_ProjectHierarchy": XXXX,
"ObjectID": XXXX,
"c_L3KanbanStage": "In Progress",
"_ValidFrom": {
"$gte": "2014-03-03",
"$lt": "2014-04-15"
}
}
Then it gives me two snapshots. I am not sure, if I am trying something wrong or missing something. Can somebody please help me on this.
Basically I want to achieve something like, within two dates I want to get each transition in the value for c_L3KanbanStage
{
"_ProjectHierarchy": XXXXX,
"ObjectID": XXXXX,
"_PreviousValues.c_L3KanbanStage": {"$in": ["Advance Investigation"]},
"c_L3KanbanStage": {"$in": ["Closed","Verified"]}
}
Can any one please help me on the same.
Upvotes: 0
Views: 166
Reputation: 98
Your approach should work, but here are some reasons you might not get the expected query results.
If you query by ObjectID, you should only need to specify _ProjectHierarchy if the artifact moved from one project to another at some point. Try removing that.
{
"ObjectID": XXXXX,
"_PreviousValues.c_L3KanbanStage": { "$in": ["Advance Investigation"] },
"c_L3KanbanStage": { "$in": ["Closed","Verified"] }
}
You can also use $gt and $lt for state fields. For example,
{
"ObjectID": XXXXX,
"c_L3KanbanStage": { "$gte": "Closed" },
"_PreviousValues.c_L3KanbanStage": { "$lt": "Closed" }
}
Once you see the expected snapshots without specifying a date range, try adding that part to the query.
{
"ObjectID": XXXXX,
"c_L3KanbanStage": { "$gte": "Closed" },
"_PreviousValues.c_L3KanbanStage": { "$lt": "Closed" }
"_ValidFrom": {
"$gte": "2014-03-03",
"$lt": "2014-04-15"
}
}
In case it helps, the Lookback API documentation has examples of state transition queries.
Upvotes: 1