Discussions

Ask a Question
Back to all

Querying WorkOrder vs WpTree

I have a question about querying WorkOrder vs WpTree. My goal in using WpTree is to get a list of all work orders that are related - parents and children. I assumed that WpTree would do that. Here is what I am seeing when I query your stage environment.

With work order number "C5391660-00232" if I query WorkOrder, I get a result. Here is the query object:

{
"QueryExpression": {
"Criteria": {
"Conditions": [
{
"PropertyName": "Number",
"Operator": "Equal",
"Values": [
"C5391660-00232"
]
}
],
"FilterOperator": "And"
},
"Distinct": true,
"PropertySet": {
"Properties": [
"",
"CustomFields.
"
]
},
"Count": 10,
"FirstResultIndex": 0
}
}

If I query WpTree, I get no results. Here is the query:

{
"QueryExpression": {
"Criteria": {
"Conditions": [
{
"PropertyName": "ParentWorkOrder.Number",
"Operator": "Equal",
"Values": [
"C5391660-00232"
]
}
],
"FilterOperator": "And"
},
"Distinct": true,
"PropertySet": {
"Properties": [
"*"
]
},
"Count": 10,
"FirstResultIndex": 0
}
}

With work order number "J5044995-00065" if I query WorkOrder, I get a result. Here is the query object:

{
"QueryExpression": {
"Criteria": {
"Conditions": [
{
"PropertyName": "Number",
"Operator": "Equal",
"Values": [
"J5114861-00035"
]
}
],
"FilterOperator": "And"
},
"Distinct": true,
"PropertySet": {
"Properties": [
"",
"CustomFields.
"
]
},
"Count": 10,
"FirstResultIndex": 0
}
}

If I query WpTree, I get 4 resulting work orders, including the parent work order. Here is the query:

{
"QueryExpression": {
"Criteria": {
"Conditions": [
{
"PropertyName": "ParentWorkOrder.Number",
"Operator": "Equal",
"Values": [
"J5044995-00065"
]
}
],
"FilterOperator": "And"
},
"Distinct": true,
"PropertySet": {
"Properties": [
"*"
]
},
"Count": 10,
"FirstResultIndex": 0
}
}

Why doesn't the WpTree query for "C5391660-00232" return the parent work order? Is there a better way to just get all related work orders than using WpTree? Or is there a better way to build my query? I also tried using "PropertyName": "RootWorkOrder.Number" in my query but got the same results.