Show specific reports in a read-only grid

I have two record types:

1. Asset

2. Match Report

The Assets have a one-to-many relation with the Match Report

I want to show an Asset specific grid where it shows all the Match Reports of that Asset

I have created a read-only-grid where I query that the assetId should match the match_report.asset.assetId

This only works if the Asset has a minimum of one Match Report created

If there are no match reports available linked to the asset, the query will fetch all match reports from all assets and show them in the grid.

Can someone help me to make sure the grid is empty if there are no match reports available? 

This is my query in expression: 

a!queryLogicalExpression(
  operator: "AND",
  filters: {
    a!queryFilter(
      field: "asset.assetId",
      operator: "=",
      value: ri!AM_Match_Report.asset.assetId
    )
  },
  ignoreFiltersWithEmptyValues: true
)

  Discussion posts and replies are publicly visible

Parents
  • You probably need to put an if() statement around the entire query. What you want to happen is that you should only query IF there is an asset ID to filter on. Otherwise, you should just return nothing. So, you could set up a query like this to define the data for your grid:

    if(
      isnull(ri!AM_Match_Report.asset.assetId),
      null,
      a!queryEntity(
        entity: cons!YOUR_CONSTANT_HERE,
        query: a!query(
          pagingInfo: a!pagingInfo(
            startIndex: 1,
            batchSize: 10
          ),
          logicalExpression: a!queryLogicalExpression(
            operator: "AND",
            filters: {
              a!queryFilter(
                field: "asset.assetId",
                operator: "=",
                value: ri!AM_Match_Report.asset.assetId
              )
            },
            ignoreFiltersWithEmptyValues: true
          )
        )
      )
    )

    I'm not sure how you are actually using this in your grid, so it's possible the null on line 3 is not correct in your scenario - however, you can replace that with other things (e.g. todatasubset({}) if you want it to return a blank datasubset for your grid).

  • Hi Peter, thanks for your answer. Also not working unfortunately. Since the assetId is never NULL. I can not imagine this should be very difficult to achieve.. This should be basic functionality right? Am I just overcomplicating it?

  • 0
    Appian Employee
    in reply to Ozin

    Yeah something isn't quite adding up. Did you try running the query separate (like directly in an expression rule) and trying different inputs to make sure it works? I'm also confused about the value in the filter expression you gave above. This looks like it's coming from a rule input for Match_Report. However, shouldn't this come from an Asset rule input if you're display the corresponding match reports for the given asset?

Reply
  • 0
    Appian Employee
    in reply to Ozin

    Yeah something isn't quite adding up. Did you try running the query separate (like directly in an expression rule) and trying different inputs to make sure it works? I'm also confused about the value in the filter expression you gave above. This looks like it's coming from a rule input for Match_Report. However, shouldn't this come from an Asset rule input if you're display the corresponding match reports for the given asset?

Children
No Data