0

I am facing an issue with LookBack API.

I want to get all the defects, which are in Submitted State to show in a chart as per on a date in range. I am able to retrieve the defects, based on State.

However when I use

{
        "_TypeHierarchy" : "Defect",
        "Project":<ProjectID>,
         "Release" :<ReleaseOID>,
        "_PreviousValues.State" : { $lt : "Submitted"},
        "State" : "Submitted" ,
        "_ValidFrom" : {
            $gte : "2014-02-24TZ",
            $lt: "2014-02-26TZ"
        }
    }

This returns to me all the defects, which have been modified in either way, which may be the owner or any general edit.Hence the result count is quite large. I want only based on State. Is this possible, Am I trying something wrong.

I also tried to fetch only the version number, 0, for the same. But this is not a good solution, since I also need to show the closed defects as well, and they will never be in Revision 0.

I cant use at, because it supports only equals operator. Please help me, I think I am missing something quite simple here, but cant figure out on my own.

Trever Shick
  • 1,734
  • 16
  • 17

2 Answers2

1

I think the problem may be in your _PreviousValues.State criteria clause. $lt:"Submitted" will also pull null values, or snapshots that may not even have State in PreviousValues. I think to get you closer to what you need you must add the following clause:

$and : [{"_PreviousValues.State":{$ne:null}}, {"_PreviousValues.State":{$lt:"Submitted"}}]

This will filter out the nulls which I believe is giving you the problem. If the problem persists, consider adding fields:{"State":1,"Name":1, "_ValidFrom":1,"_ValidTo":1,"_TypeHierarchy":1,"FormattedID":1,"_PreviousValues":1,"_PreviousValues.State":1}, hydrate : ['State','_PreviousValues.State'], to your query and adding the resulting output to your original question.

Trever Shick
  • 1,734
  • 16
  • 17
1

I hope you found the answer to your question as it has been over an year since this question was posted. Either way, I am going to answer this.

Instead of using:

"_PreviousValues.State" : { $lt : "Submitted"},

Try previous values as an array and specify exact values. For instance:

"_PreviousValues.ScheduleState": ["Closed", "Open", "Fixed"]

I hope it helps! Thanks Kay

kartik
  • 293
  • 4
  • 9