Post

1 follower Follow
2
Avatar

How can I do a compound and entity match condition in REST API?

I would like to query Timesheet items with a compound condition and an entity match using the REST API.

The "condition" type is not documented and the REST API docs have very few examples with regards to conditions. 

I have been unable to figure out how to setup a compound condition (such as AND or OR).  I have also not been able to do an "IN" type condition against another query. 

Additionally and of equal importance I have not been able to compare with 'Equal' a field like "ReportedBy" which references an entity.  Using an entity id as the match value results an in error that the value is not acceptable for that type.

Have compound conditions and entity match been implemented on the REST API?  If so, can we get an example of how that works exactly?

Steven D. Harris Answered

Please sign in to leave a comment.

2 comments

0
Avatar

Hi Steven,

Thank you for your question. I forwarded your inquiry to our R&D experts who will reach out to you soon.

For the future, please let me suggest to post any API-related questions on our Developers forum. Our R&D team monitors the Developers forum and will be able to answer your questions in a much faster manner :). Here is the link to the forum >>   https://clarizen.zendesk.com/forums/22177967-Developers.

Thank you,

Diana

Diana Sandura 0 votes
Comment actions Permalink
0
Avatar

Hi Steven,

Our experts prepared a couple of examples for you. The first one shows how to use OR and a

reference field (such as ReportedBy) in the Equal operator and another one for IN operator.

 

Please note that the examples may not work correctly in the production environment until our fix release scheduled for June 29th, where the REST API should be addressed.

 

 

{

        "fields": [

          "Comment",

          "Duration",

          "ReportedBy"

        ],

        "typeName": "Timesheet",

        "where": {

          "conditions": [

            {

              "leftExpression": {

                "fieldName": "State"

              },

              "operator": "Equal",

              "rightExpression": {

                "value": "/State/Approved"

              }

            },

            {

              "leftExpression": {

                "fieldName": "State"

              },

              "operator": "Equal",

              "rightExpression": {

                "value": "/State/Submitted"

              }

            },

            {

              "leftExpression": {

                "fieldName": "CreatedBy"

              },

              "operator": "Equal",

              "rightExpression": {

                "value": "/User/1aff5e17-36b6-4ebd-97b1-40a0a4ab2974"

              }

            },

            {

              "leftExpression": {

                "fieldName": "ReportedBy"

              },

              "operator": "Equal",

              "rightExpression": {

                "value": "/User/1aff5e17-36b6-4ebd-97b1-40a0a4ab2974"

              }

            }

          ],

          "_type": "Or"

        },

      }

    }

 

 

{

  "Fields": "ActualEffort,Title,Work",

  "Orders": [

    {

      "FieldName": "Title",

      "Order": "Ascending"

    }

  ],

  "TypeName": "Issue",

  "Where": {

    "LeftExpression": {

      "FieldName": "CreatedBy"

    },

    "Operator": "In",

    "RightExpression": {

      "Query": {

        "TypeName": "User",

        "Where": {

          "LeftExpression": {

            "FieldName": "ExternalId"

          },

          "Operator": "Equal",

          "RightExpression": {

            "Value": "1aff5e17-36b6-4ebd-97b1-40a0a4ab2974"

          }

        },

        "_type": "EntityQuery"

      },

      "_type": "QueryExpression"

    }

  },

}

 

Diana Sandura 0 votes
Comment actions Permalink