You need to sign in to do that
Don't have an account?
Rahul
hellow friends, Iam getting the following error."Error: Compile Error: A non foreign key field cannot be referenced in a path expression: Accounts__r at line 16 column 25. Please help"
trigger updateborrowerinbucket1 on Account (after insert, after update) {
set<id> setid = new set<id>();
list<bucket1__C> bucketlist = new list<bucket1__C>();
for(Account a : trigger.new){
setid.add(a.Bucket_1__c);
}
for(bucket1__c bb : [select id,name,Borrower_Name__c,(select id, name, Mobile_Number__c from Accounts__r)from bucket1__C]){
bucket1__C bb2 = new bucket1__C();
bb2.id=bb.id;
bb2.count_of_patients__c=bb.Accounts__r.size();
bb2.Borrower_Name__c=bb.Accounts__r.Name;
bucketlist.add(bb2);
}
update bucketlist;
}
set<id> setid = new set<id>();
list<bucket1__C> bucketlist = new list<bucket1__C>();
for(Account a : trigger.new){
setid.add(a.Bucket_1__c);
}
for(bucket1__c bb : [select id,name,Borrower_Name__c,(select id, name, Mobile_Number__c from Accounts__r)from bucket1__C]){
bucket1__C bb2 = new bucket1__C();
bb2.id=bb.id;
bb2.count_of_patients__c=bb.Accounts__r.size();
bb2.Borrower_Name__c=bb.Accounts__r.Name;
bucketlist.add(bb2);
}
update bucketlist;
}
In Parent-to-Child query, it's fetch parent record and related all child records
like, one account have multiple contact(List of contact).
instead of yours, use this bb.Accounts__r[0].Name (line no. 16)
Just try this,
Thanks,
All Answers
In Parent-to-Child query, it's fetch parent record and related all child records
like, one account have multiple contact(List of contact).
instead of yours, use this bb.Accounts__r[0].Name (line no. 16)
Just try this,
Thanks,