The Visual Builder Cloud Service Blog

Complex Queries in Visual Builder

John Jullion-Ceccarelli
Product Manager

Often, you have to filter a data set based on multiple search criteria like in the above image.

In this case, you want to only create filterCriterion items for fields that have a value. Any field with null/undefined/empty string you want to skip. To accomplish this, create an object to hold your filter criteria with each of the fields named exactly as the parameters you need to pass in. In our case it's SrNumber and StatusCdMeaning. For Business Objects and Fusion Apps REST endpoints, you can define this filterCriteria variable using a Type from Endpoint to make sure the field names match exactly.

Then add a page function that looks like this:

  PageModule.prototype.getQueryCriteria = function(filterObject) {
    var filterProps = Object.keys(filterObject);
    var criteria = [];
    filterProps.forEach(key => {
      var value = filterObject[key];
      if (value !== undefined && value !== null && value !== '') {
          attribute: key,
          op: "$co",
          value: value
    return {
      criteria: criteria

Finally, hook up the filter button's ojAction chain to contain an Assign Variables action. In the Assign Variables, map the SDP's filterCriterion as follows. Make sure it's set to be an expression and not static text.


Note that we don't specify a top-level operand on the filterCriteria so it will automatically use $and for SrNumber and SrStatus.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.