Related record filtering issue in 25.2

Certified Associate Developer

O/P - 1

Output_1

O/P - 2

Output_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

Parents Reply Children
  • +1
    Certified Lead Developer
    in reply to rahulb1099

    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(). 

  • 0
    Certified Associate Developer
    in reply to Harsha Sharma

    yeah, may be you're right, that is not supported by a!relatedRecordData(). ~Thanks for your time.