You need to sign in to do that
Don't have an account?
Campaign Member populate lookup trigger not working
Hey guys i have created a Account Lookup field on a Campaign Member object which i'm currently using a trigger to populate.
Does anyone know if this is possible?
At the moment i cant seem to populate any lookup fields even though the soql is getting the correct data. After the trigger runs the Account field in the Campaign Member remains empty.
Any help would be appreciated.
Here is the trigger below:
trigger CampaignMemberLookup on CampaignMember (before update) {
List<Id> contactID = new List<Id>();
for (CampaignMember cm : trigger.new) {
CampaignMember old_cm = Trigger.oldMap.get(cm.Id);
if (cm.ContactId != old_cm.ContactId) {
contactID.add(cm.ContactId);
}
}
List<Contact> myList= [Select Id, Account__c FROM Contact WHERE Id IN : contactID];
Map<Id, Account__c > myMap= new Map<Id, Account__c >();
for (Contact c : myList) {
tradingMap.put(c.Id, c.Account__c );
}
for (CampaignMember cm : trigger.new) {
if (myMap.containsKey(cm.ContactId)) {
cm.Account__c = myMap.get(cm.ContactId);
}
}
try this trigger Account__c to AccountId in Contact SOQL and changed MAP<ID , Account__c> to Map<ID ,ID>
Let me know with your resluts.
Tried your version but i'm still getting the same result, Account lookup remains blank once a Lead is converted into a Contact.