You need to sign in to do that
Don't have an account?
roni shore
Filed value not getting updated
Scenario: when a lead is created, then 2 sibling leads are created, now we convert one of the sibling lead and we get a realted contact.
problem -So, can i fetch a field values of a converted lead and then populate it in another sibling lead
m trying with below code, isnt helping..please suggest
public static void updateRelContactAfter(list<Contact> lstNewContact) {
System.debug('lstNewContact===>'+lstNewContact);
set<String> setEmail = new set<String>();
map<String,Contact> mapLead = new map<String,Contact>();
for(Contact c:lstNewContact){
setEmail.add(c.Email);
mapLead.put(c.Email,c);
}
System.debug('mapLead===>'+mapLead);
Id salesRTID = RecordTypeManager.getRecordTypeId('Lead.Sales_Marketing');
List<Lead> leadList = [SELECT Id,RelatedContact__c,Email,RecordTypeId FROM Lead
WHERE Email IN:setEmail AND RecordTypeId =:salesRTID AND IsConverted != True];
system.debug('LeadList===>'+ leadList);
list<lead> leadUpdateList = new list<lead>();
for(Lead l:leadList){
lead lnew = new lead();
lnew.id = l.id;
lnew.Related_existing_Contact__c = mapLead.get(l.email).Id;
system.debug('checkpnt===>'+ lnew.Related_existing_Contact__c);
leadUpdateList.add(lnew);
}
System.debug('leadUpdateList===>'+leadUpdateList);
if(leadUpdateList != null){
update leadUpdateList;
System.debug('leadUpdateList==After=>'+leadUpdateList);
}
}
problem -So, can i fetch a field values of a converted lead and then populate it in another sibling lead
m trying with below code, isnt helping..please suggest
public static void updateRelContactAfter(list<Contact> lstNewContact) {
System.debug('lstNewContact===>'+lstNewContact);
set<String> setEmail = new set<String>();
map<String,Contact> mapLead = new map<String,Contact>();
for(Contact c:lstNewContact){
setEmail.add(c.Email);
mapLead.put(c.Email,c);
}
System.debug('mapLead===>'+mapLead);
Id salesRTID = RecordTypeManager.getRecordTypeId('Lead.Sales_Marketing');
List<Lead> leadList = [SELECT Id,RelatedContact__c,Email,RecordTypeId FROM Lead
WHERE Email IN:setEmail AND RecordTypeId =:salesRTID AND IsConverted != True];
system.debug('LeadList===>'+ leadList);
list<lead> leadUpdateList = new list<lead>();
for(Lead l:leadList){
lead lnew = new lead();
lnew.id = l.id;
lnew.Related_existing_Contact__c = mapLead.get(l.email).Id;
system.debug('checkpnt===>'+ lnew.Related_existing_Contact__c);
leadUpdateList.add(lnew);
}
System.debug('leadUpdateList===>'+leadUpdateList);
if(leadUpdateList != null){
update leadUpdateList;
System.debug('leadUpdateList==After=>'+leadUpdateList);
}
}
roni shore
checkpnt===>'debug gives the ID, but in system it show deleted,
Raj Vakati
Can you print other debug logs and see what is ther error is showing and can you share the debug logs
roni shore
Just figured out contactid is coming wrong in debugs, thats y its showing data not available in sytem
But this is wierd, how come id or a record will come different
Raj Vakati
You need to use __r.Id .. please close this thread