we have a custom parent object and attachment as a child object. we have one reference field which is the parentId of attachment. when we try to add a condition to look for the parentId on the reference field then it is not working. where clause is not getting added to the attachment query
Can you post a screenshot of your condition configuration?
Hi Rob,
we have two models “checkInRecords” and “CheckIn”. we are applying the child relationship condition on attachment object in “CheckIn” model. For parentId conditions, we are providing values from “checkInRecords” model. which is sequentially up from “CheckIn” model.
Below are the screenshots.
The query generated after page load having no conditions in attachments: SELECT CreatedDate,Check_Out__r.CreatedDate,Check_Out__r.Id,(SELECT Name,Parent.Id,Id FROM Attachments LIMIT 10),Check_Out__c,Check_Out__r.Name,(SELECT Body,ParentId,Id FROM Notes LIMIT 10),Id,CurrencyIsoCode FROM Participant_Check_In_Out_History__c WHERE (Id in (‘a3pg00000006t4dAAA’,‘a3pg00000006t3VAAQ’,‘a3pg00000006sjoAAA’,‘a3pg00000006sjQAAQ’,‘a3pg00000006sjZAAQ’,‘a3pg00000006sjPAAQ’,‘a3pg00000006silAAA’,‘a3pg00000006shiAAA’,‘a3pg00000006shYAAQ’,‘a3pg00000006shOAAQ’,‘a3pg00000006sQ8AAI’,‘a3pg00000006sPPAAY’,‘a3pg00000006p6nAAA’,‘a3pg00000006oxzAAA’,‘a3pg00000006RjLAAU’,‘a3pg00000005tcYAAQ’)) ORDER BY CreatedDate DESC LIMIT 51
please do let me know if you need more details
Thanks
That is very interesting.
If checkinRecords is a parent to Checkin. And you want to limit the attachments under checkin - I don’t believe you need any conditions on the child relationship. We’re automatically going to associate the attachments with the appropriate Checkin record. And it can only associated with one “chekinRecords” record.
But I’m sure I’m missing somthing.
Doesn’t the WHERE Id IN (…) clause represent the condition on the Checkin model? The list of Id’s in the IN clause are the CheckOut__r Id’s in the CheckinRecords model.
What we might be missing is the conditions on the child relationship of Check_Out__c in the CheckinRecords model.
yes, without adding any condition on attachment object then it takes parenetId as a checkIn record Id. But in our case, the parentId is the other reference field. so we have to provide the condition on attachment so that it will map to correct parent object.
Yes, list of Ids in the IN clause is the CheckOut__r Id’s in the from the CheckinRecords model. but there is nothing in where clause on child relationship attachment object.
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.