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
It looks like your interface input and grid field are querying the same data source. Is that true? Could you just pass "assetId" into the interface rule with the grid field?
It doesn't work. Little bit lost here. How do you usually do this? I just want to show the match reports of only that player in a site on a seperate view.
Change the input to the interface to an integer "assetId" and update the queryFilter to: a!queryFilter( field: "asset.assetId", operator: "=", value: ri!assetId )...otherwise it looks like you are querying the data twice. This may not address your issue of the query returning a null.
What happens if you take an assetID that you know has match reports and plug it directly into line 36 instead of ri!AM_Match_Report.asset.assetId? Does that work? If it does, then you should be able to completely ignore AM_GetReportById. Your interface rule should include a rule input for "assetId" of type Integer, and this input should replace what you originally had as the variable on line 36. Your reference in the record type should be like this:
rule!AM_AssetPerformance( assetId: rf!assetId )
If this still doesn't work, then there is likely an issue with the data in the database. You may not have set up your relationship correctly or haven't inserted the correct data into the database. I'd suggest investigating the CDTs you created to make sure you have the correct relationship (it should be M:1 with asset referenced inside of matchReport).
This worked!! Thank you so much!
The original interface input was returning a null(), when no "Match Reports" were found. This made the input, "ri!AM_Match_Report.asset.assetId", to the query within the grid field null(), thats why when you had the "ignoreFiltersWithEmptyValues=true" it would return all Match Reports and work when it found corresponding "Match Reports".