3 respuestas

Hi, try this below code....
trigger Sample_tri on Case (after insert) {
if(trigger.isInsert && trigger.isAfter){
Map<ID,String>cids=new Map<ID,String>();
for(Case c:trigger.new){
if(c.ContactId!=null && c.email__c!=null){
String[] arrName =c.email__c.split('@');
system.debug('--------'+arrName[1]);
cids.put(c.ContactId,arrName[1]);
}
}
List<Contact>ccc=[select id,lastname from Contact where id IN:cids.keySet()];
for(contact c:ccc){
c.lastName=cids.get(c.id);
}
update ccc;
}
}