You need to sign in to do that
Don't have an account?
Sarah Robertson
email message to address update
Hi I'm trying to edit this existing trigger, I want to add a condition so it runs when the email condition only contains certain text
It's not liking this part of the apex :
Here's the code I'm using, can anyone give me any pointers as to where I am going wrong ?
Thanks so much Sarah :
trigger UpdateTo on EmailMessage (before insert) {
//set<id> CaseIds = new set<Id>();
map<Id,EmailMessage> MapEmailMessage = new map<Id,EmailMessage>();
List<Case> newList = new List<Case>();
for(EmailMessage e:trigger.new){
MapEmailMessage.put(e.ParentId,e);
}
list<Case> lstC = [select Id,To__c from Case where id in:MapEmailMessage.keyset()];
for(Case c:lstC){
if(MapEmailMessage != null && MapEmailMessage.get(c.Id) != null )
c.To__c = MapEmailMessage.get(c.Id).ToAddress;
newList.add(c);
}
if(newList.size()>0)
{
update newList;
}
}}
It's not liking this part of the apex :
If(EmailMessage.ToAddress.contains=('SignedOrder')){
Here's the code I'm using, can anyone give me any pointers as to where I am going wrong ?
Thanks so much Sarah :
trigger UpdateTo on EmailMessage (before insert) {
//set<id> CaseIds = new set<Id>();
map<Id,EmailMessage> MapEmailMessage = new map<Id,EmailMessage>();
List<Case> newList = new List<Case>();
for(EmailMessage e:trigger.new){
If(EmailMessage.ToAddress.contains=('SignedOrder')){
MapEmailMessage.put(e.ParentId,e);
}
list<Case> lstC = [select Id,To__c from Case where id in:MapEmailMessage.keyset()];
for(Case c:lstC){
if(MapEmailMessage != null && MapEmailMessage.get(c.Id) != null )
c.To__c = MapEmailMessage.get(c.Id).ToAddress;
newList.add(c);
}
if(newList.size()>0)
{
update newList;
}
}}
Use below code
Hope this will work
Thanks
karthik