You need to sign in to do that
Don't have an account?
duckyforce
Invalid foreign key relationship
Hey guys,
I'm getting an Invalid foreign key relationship on Contact.CampaignMember that I can't seem to figure out.
for(Contact contact : Trigger.new) { if (contact.User_Testing__c = 'True' && contact.CampaignMember.CampaignID != '70170000000BdE2' ) conIds.add(contact.ID); }
Do you have any relationship between contact and campaign member?
Thanks
Ankit Arora
Blog | Facebook | Blog Page
Hi
I am trying to copy address from one custom object to another custom object but i got error
Error: Compile Error: Invalid foreign key relationship: Address__c.Accounting__c
code:
trigger triggerupdate on Address__c (after insert,after update) {
List<id> Accountid=new List<id>();
List<id> Addressid=new List<id>();
for(Address__c objadd:trigger.new){
Addressid.add(objadd.id);
Accountid.add(objadd.Accounting__c.id);
}
List<Accounting__c> objacc=[select id,Billing_City__c,Billing_State__c,Billing_Country__c from Accounting__c where id=:Accountid];
Map<id,Accounting__c> objmap=new Map<id,Accounting__c>();
for(Accounting__c obja:objacc){
objmap.put(obja.id,obja);
}
List<Accounting__c> objlist=new List<Accounting__c>();
for(Address__c objadd:trigger.new){
Accounting__c objaccount=objmap.get(objadd.Accounting__c.id);
if ( objaccount == null ) {
continue;
}
objaccount.Billing_State__c = objadd.Billing_State__c;
objaccount.Billing_City__c = objadd.Billing_City__c;
objaccount.Billing_Country__c = objadd.Billing_Country__c;
EmpToUpdate.add(objaccount);
}
update objlist;
}
Please if u know reply me....Thanks
I think you'd want to use something like Address__r.Accounting__c
You need to use __r if you're going through a lookup.