You need to sign in to do that
Don't have an account?
Vinu Varghese
Error in select entry in a relational object
I have the following select statement, but it giving me error. When I query seperately it works. I tried under query editor also. Same error.
List<Deposit_Detail__c> depositDetailList = [Select Deposit__r.Name, Id,Amount__c, Member_Name__c from Deposit_Detail__c Where Id IN :trigger.new];
please help me.
Thanks
List<Deposit_Detail__c> depositDetailList = [Select Deposit__r.Name, Id,Amount__c, Member_Name__c from Deposit_Detail__c Where Id IN :trigger.new];
please help me.
Thanks
As you are using trigger.new you need to use it inside a code snippet that has access to these records in the trigger.new can you once check if it helps if you add the list of id's of the trigger.new records to a set and then using the below snippet?
Also, please do note that the records in trigger.new would have record id only when it is after insert or in update scenarios.
I hope you are not performing the above snippet in before insert, as the records would not have recordid's.
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
Select Deposit__r.Name, Id,Amount__c ^ ERROR at Row:1:Column:8 Didn't understand relationship 'Deposit__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name.
Note that its nothing to do with trigger.new. I removed the trigger.new from the select entry. still has the folowing error. The same way I did it in other triigers/classes and its works. The following code works as an example:
List<Receipts_Payments__c> memberList = [Select Member__r.Id, Member__r.Name, Member__r.Email__c,
Id, Member__c, RecordTypeId from Receipts_Payments__c where Id IN :trigger.new
];
But this one doesn't.
List<Deposit_Detail__c> depositDetailList = [Select Deposit__r.Name, Id,Amount__c, Member_Name__c from Deposit_Detail__c Where Id IN :trigger.new];
I even tried to use child to parent relationship query, that doesn't too.
I don't know whether the error is related to object itself.
This "Lookup field name"(inside the child object i.e Position here) should be exactly same as the "Parent Object API Name"
Child Object API Name: Deposit_Detail__c
Child Relationship Name : Deposit_Details