Creating query chains
To build your card data, add query chains to the queries section. 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
- Learn how to create GraphQL queries. For more information, see Writing a query for a business object event.
- Learn about the data model. For more information, see Data model.
- Create or modify an existing card. For more information, see Card builder.
Procedure
- To add query 1, on the Queries tab, click Add.
- Select an existing group name or enter a group name and click Create new.
- 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\" } ] }" }
- 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}}" } ] }
- To add query 2, on the Queries tab, click Add.
- Select the group name that you created or used in step 2.
- On the Query tab, add a query name, query,
and query variables. Include the variables from the result of the previous query transformation.
- 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 inventoryType location { locationName locationIdentifier } quantity quantityUnits daysOfSupplyBelowLowerThreshold quantityBelowLowerThreshold daysOfSupplyAboveUpperThreshold quantityAboveUpperThreshold velocityCode daysOfSupply value valueCurrency plannerCode product { status name partNumber plannerCode category { name } } } } } } }
- Example of query variables
-
{ "tenantId": "{{tenantId}}" }
- On the Transform tab, add a
transform.
- Example of a transform
-
{ "errors": "{{ #? this.errors }}", "openSalesOrderCount1": 2, "results": [ { "openSalesOrderCount": "{{$requests[0].output.totalCount[0]}}" }, { "inventorySearchResults": "{{this.data.inventorySearchResults.totalCount}}" } ] }
The
requests[0].output
in the preceding example refers to the output of the first query after the transform is applied.