Adding multiple queries

To gather data for your card, create multiple independent queries in the Queries group. You can add up to five queries to the query section of a card, which then displays the aggregated results from each query group.

Before you begin

Procedure

  1. To add query 1, on the Queries tab, click Add.
  2. Select an existing group name or enter a group name and click Create new.
  3. On the Query tab, add a query name, query, and query variables.
    Example of a query
    query dashboardMetrics($tenantId: String, $customerFilter: BooleanExp = {CONSTANT_VALUE: true}, $supplierFilter: BooleanExp = {CONSTANT_VALUE: true}, $originFilter: BooleanExp = {CONSTANT_VALUE: true}, $destinationFilter: BooleanExp = {CONSTANT_VALUE: true}) {
      openSalesOrder: businessObjects(
        advancedFilter: {AND: [{EQUALS: [{SELECT: "shipmentStatusByDate", type: STRING}, {type: STRING, VALUE: "NOT_SHIPPED"}]}, {EQUALS: [{SELECT: "orderType", type: STRING}, {type: STRING, VALUE: "OUTBOUND"}]}, $customerFilter, $supplierFilter, $originFilter, $destinationFilter]}
        cursorParams: {first: 0}
        hint: {viewId: "graph"}
        simpleFilter: {tenantId: $tenantId, type: Order}
      ) {
        totalCount
      }
    }
    Example of query variables
    {
      "tenantId": "{{ tenantId }}",
      "customerFilter": "{ \"EQUALS_ANY\": [ {\"SELECT\": \"buyer.id\", \"type\": \"STRING\" }, { \"VALUES\": {{ inventory.appliedFilters.Customer.ids }}, \"type\": \"STRING\" } ] }",
      "supplierFilter": "{ \"EQUALS_ANY\": [ {\"SELECT\": \"vendor.id\", \"type\": \"STRING\" }, { \"VALUES\": {{ inventory.appliedFilters.Supplier.ids }}, \"type\": \"STRING\" } ] }",
      "originFilter": "{ \"EQUALS_ANY\": [ {\"SELECT\": \"shipFromLocation.id\", \"type\": \"STRING\" }, { \"VALUES\": {{ inventory.appliedFilters.Origin.ids }}, \"type\": \"STRING\" } ] }",
      "destinationFilter": "{ \"EQUALS_ANY\": [ {\"SELECT\": \"shipToLocation.id\", \"type\": \"STRING\" }, { \"VALUES\": {{ inventory.appliedFilters.Destination.ids }}, \"type\": \"STRING\" } ] }"
    }
  4. On the Transform tab, add a transform.
    Example of a transform
    {
    	"errors": "{{#? this.errors}}",
    	"pageInfo": "{}",
    	"totalCount": [
    		"{{this.data.openSalesOrder.totalCount}}"
    	],
    	"results": [
    		{
    			"openSalesOrdersCount": "{{this.data.openSalesOrder.totalCount + 100}}"
    		}
    	]
    }
  5. To add query 2, on the Queries tab, click Add.
  6. Select an existing group name that is not used in step 2 or enter a group name and click Create new.
  7. On the Query tab, add a query name, query, and query variables.
    Example of a query
    query InventorySearchResults($tenantId: String, $searchFieldsForString: SearchFieldsForStringInput, $cursorId: String, $pageLength: Int = 20, $sortBy: String = "id", $sortOrder: SortOrder = DESC) {
      inventorySearchResults: businessObjects(
        hint: {viewId: "graph"}
        simpleFilter: {type: Inventory, tenantId: $tenantId, searchFieldsForString: $searchFieldsForString}
        advancedFilter: {EXISTS: [{SELECT: "createReceived", type: STRING}]}
        cursorParams: {first: $pageLength, after: $cursorId, sort: {fieldPath: $sortBy, order: $sortOrder}}
      ) {
        totalCount
        pageInfo {
          hasNextPage
          endCursor
        }
        edges {
          cursor
          object {
            ... on Inventory {
              id
              createReceived
            }
          }
        }
      }
    }
    Example of query variables
    {"tenantId":"{{tenantId}}"}
  8. On the Transform tab, add a transform.
    Example of a transform
    {
    	"errors": "{{ #? this.errors }}",
    	"openSalesOrderCount1": 2,
    	"results": [
    		{
    			"inventorySearchResults": "{{this.data.inventorySearchResults.totalCount}}"
    		}
    	]
    }

What to do next

After you add the queries, you can select the data that you want to show on the card. The data is aggregated from each query group.