O/P - 1
O/P - 2
O/P - 3
When I directly query the comments table with a filter to fetch comments where the audit is null, it returns the expected results(O/P - 1). However, when I apply the same filter in a related record query from the main test table, it does not return any comments(O/P - 2). Interestingly, if I remove the audit filter, the related record query returns the correct data(O/P - 3). Any idea what could be causing this issue?
Discussion posts and replies are publicly visible
Not sure what you try to do...
To fetch a single record item and its related records, you just add that relationship to the fields list.
The relationship to 'testAudit1' is referenced in the filters, you should have a field here. If you want to fetch comments where audit is null why not put filter simply as
a!queryfilter( field:RS Test Comment.auditId, operator:"is null")
Its difficult to understand the structure and relationship with the records here with the given details
As per your query, you mentioned that the "is null" filter fails to return results in a related record query. However, I tried to replicate this scenario, and in my case, the "is null" filter works as expected for related records.
Could you please clarify your setup or provide more details about the issue you are facing?
Thank you for your response. The relationship between Comment and Audit is one-to-one, established through the field commentId. (Please disregard auditId in the Comment table, as the actual Comment table does not include an auditId field.) FYI commentId is unique in audit table.Test -> Comment -> audit
The relationship between Comment and Audit is one-to-one, established through the field commentId. I need comments with null audit. Its working when we directly query comment(O/P - 1) but its not not working if I apply same filter in related record(O/P - 2).
In that case for all the scenarios can you try referencing till the audit field instead of (as it looks like now) till relationship reference.
In your screenshots if you focus on the icons for field reference you can notice the testAudit1 is a relation ship. But when you reference a field from the relationship then icon should be of the field. So put correct field reference in all three scenarios and then check. As of now the configuration seems incorrect so not right to compare the results and behavior.
If you define a 1-1 relationship, then you cannot query items not having a valid relationship.
Test (id, commentId)
one to many through test_id
Comment (comment_id, test_id)
one to one through comment_id
Audit (audit_id, comment_id)
I need comments with null audit. Its working when we directly query comment(O/P - 1) but its not not working if I apply same filter in related record(O/P - 2).
I tried adding audit field as well its not working. However if we look at O/P -1 result, it's giving expected result even though we pass related record in field(line 12).
I tried to test the scenario like yours and it is interesting! And so far I feel the difference in behavior between O/p 1 or O/p 3 versus o/P 2 is due to a!relatedRecordData().
In scenario 2, you are querying on Record 'Test'. Then in related record you are filtering the 'Comment' record but you are also trying to filter the audit record which is a 2nd level related record to 'Test' and 1st level to 'Comment' record.
As per description given for a!relatedRecordData() there is a hint of suggestion to filter using only the referenced related record type! In your case you should filter only the 'Comment' record here.
Basis the above I am gathering a!relatedRecordData() is not meant to query from 2nd level related record in the manner you are trying to.
So better to query in main filter, and I believe O/P 2 behavior , is not a code issue rather functionality supported by a!relatedRecordData().