How to construct filters in JSON?

  • 1
  • Question
  • Updated 4 years ago
I'm trying to get a list of all projects and the hours billed to them. In order to do so, I need to construct a filter in JSON. There is a test page which is supposed to help you do this, but for the life of me I cannot figure out how to use it! Expanding any of the filter fields produces a barely-formatted jumble of other fields which you may or may not need to use, so it's a lot of trial and error to figure out where to put certain values. After a few hours of working with it, I have yet to produce any search results at all. Here is the filter I've constructed. It SHOULD return all projects for a particular client, but it doesn't return any results at all. Any help here? { "page": "1", "pagesize": "10", "columnUris": [ "urn:replicon:billable-time-detail-column:client", "urn:replicon:billable-time-detail-column:project", "urn:replicon:billable-time-detail-column:billable-time-duration", null ], "sort": [], "filterExpression": { "leftExpression": { "leftExpression": null, "operatorUri": null, "rightExpression": null, "value": null, "filterDefinitionUri": "urn:replicon:billable-time-detail-filter:client" }, "operatorUri": "urn:replicon:filter-operator:text-search", "rightExpression": { "leftExpression": null, "operatorUri": null, "rightExpression": null, "value": { "uri": null, "uris": [], "bool": null, "date": null, "money": null, "number": null, "text": "", "time": null, "calendarDayDurationValue": null, "workdayDurationValue": null, "dateRange": null }, "filterDefinitionUri": null }, "value": null, "filterDefinitionUri": null } } There doesn't seem to be any documentation on how to do this anywhere on Replicon's site, either. I found one link in another forum post, but it is defunct. Replicon needs to provide a comprehensive document, with plenty of examples, on how to construct a JSON filter that their web services will accept and work with.

(Originally posted by Joseph.Bunda)
Photo of Archived Post

Archived Post, Official Rep

  • 2132 Posts
  • 6 Reply Likes

Posted 4 years ago

  • 1
Photo of Archived Post

Archived Post, Official Rep

  • 2132 Posts
  • 6 Reply Likes
Hi Joesph,

Thank you for using Replicon Community.

You could use this script.

{

  "page": "1",

  "pagesize": "20",

  "columnUris": [

    "urn:replicon:project-list-column:project",

    "urn:replicon:project-list-column:name",

    "urn:replicon:project-list-column:client",

    "urn:replicon:project-list-column:actual-billing"

  ],

  "sort": [],

  "filterExpression": {

    "leftExpression": {

      "leftExpression": null,

      "operatorUri": null,

      "rightExpression": null,

      "value": null,

      "filterDefinitionUri": "urn:replicon:project-list-filter:client"

    },

    "operatorUri": "urn:replicon:filter-operator:equal",

    "rightExpression": {

      "leftExpression": null,

      "operatorUri": "urn:replicon:filter-operator:equal",

      "rightExpression": null,

      "value": {

        "uri": "urn:replicon-tenant:zyed2-2:client:5",

        "uris": [],

        "bool": null,

        "date": null,

        "money": null,

        "number": null,

        "text": null,

Tell us if this helps.


Thanks



(Originally posted by Lingaraj Dharwad)
Photo of Archived Post

Archived Post, Official Rep

  • 2132 Posts
  • 6 Reply Likes
I would also like to see some documentation on how to build the filterExpression for web services. I opened a similar post about the same time trying to find all users in a department using a filter because I also found the test page that is used to b

(Originally posted by nathanielolson)
Photo of Archived Post

Archived Post, Official Rep

  • 2132 Posts
  • 6 Reply Likes
I'm sorry, but this doesn't help at all. It produces an internal server fault from Replicon when I use it. What I'm really looking for is a comprehensive document that has exhaustive details on how to construct a filter. It needs to list what the URI constructors mean, and why all these fields that are designated as null are even needed. Including all of the extra filter elements that aren't used seems like an obfuscation of what the filter is actually trying to accomplish. To examine this from another angle, perhaps someone could explain why something as straightforward as the following doesn't work: "filterexpression": { "leftExpression" : "urn:replicon:project-list-filter:client", "operatorUri" : "urn:replicon:filter-operator:equal", "value" : "" }

(Originally posted by Joseph.Bunda)
Photo of Archived Post

Archived Post, Official Rep

  • 2132 Posts
  • 6 Reply Likes
Aha! After some playing around, finally figured out how this works. You need to construct the JSON so that the left expression has the VALUE you're seeking, and the right expression contains the COLUMN HEADER you're comparing it to. In other words: Instead of saying "Find all meats equal to pepperoni", you'd say "Find all pepperoni equal to meat". The JSON to construct this ended up being along these lines: "filterExpression": { "leftExpression": { "leftExpression": null, "operatorUri": null, "rightExpression": null, "value": { "uri": null, "uris": [], "bool": null, "date": null, "money": null, "number": null, "text": "", "time": null, "calendarDayDurationValue": null, "workdayDurationValue": null, "dateRange": null }, "filterDefinitionUri": null }, "operatorUri": "urn:replicon:filter-operator:equal", "rightExpression": { "leftExpression": null, "operatorUri": null, "rightExpression": null, "value": null, "filterDefinitionUri": "urn:replicon:billable-time-detail-filter:client" }, "value": null, "filterDefinitionUri": null } If you swap the left and right expressions, you won't get an error, but you won't get any search results either. It took me a full day of working with this and then three of us trying random suggestions for a while before we stumbled onto the solution. Replicon, can you please include this fact in any planned documentation on how to work with this? I'm sure there are other developers out there who would find a more comprehensive guide (Or any guide at all) to working with this very handy and time-saving.

(Originally posted by Joseph.Bunda)
Photo of Archived Post

Archived Post, Official Rep

  • 2132 Posts
  • 6 Reply Likes
Actually, I have to retract my last post. The change didn't work at all, but I didn't realize it until it I searched for a different client. When the wrong client came back, I realized the filter wasn't doing anything at all, and that it was just giving me the first 20 companies in the list, regardless of what company I searched for.

(Originally posted by Joseph.Bunda)