You need to sign in to do that
Don't have an account?
V'Nath
EmailMessage Htmlbody not populated with original format with workflow or trigger
I have configured Email-to-Case functionality to my sandbox and for routing address customers will send emails with their queries, while sending emails they may include some screenshots .
Sample Email Content:
Hi this is google image and below image screen shot
What Salesforce functionality happen here is by defualt email text will be populated to description field and screen shot will get stored into attachments. and under case object we do have Emails related list where we can see original email content which customer has sent.
But the problem is my customer wants to see original content which customers has sent with in the description field .
So I have created one custom description field and datatype is Rich text area.
Customization i have done :
Created workflow rule on EmailMessage Object and tried to populate EmailMessage object HtmlBody field into Case object description (Custome field ) .
text is populated but images are not able to see and some empty textboxes i can see like below.
So above solution is not working and again i have done some tirgger on EmailMessage object to update htmlbody into desc field
like below :
first i put event after insert only but still its doesnt work for me so again i put all the events but no luck.
trigger UpdateDescTrigger on EmailMessage (after insert,after update,before insert ,before update) {
//set<id> CaseIds = new set<Id>();
map<Id,EmailMessage> MapEmailMessage = new map<Id,EmailMessage>();
for(EmailMessage e:trigger.new){
MapEmailMessage.put(e.ParentId,e);
}
list<Case> lstC = [select Id,Description__c from Case where id in:MapEmailMessage.keyset()];
for(Case c:lstC){
if(MapEmailMessage != null && MapEmailMessage.get(c.Id) != null )
c.Description__c = MapEmailMessage.get(c.Id).HtmlBody;
}
update lstC;
}
My question is : i want to automatically update HTMLBody of EmailMessage into Case Description__c (Custom field)
But if i edit case record manually and saved its working for me when i have done below trigger.
trigger updateCasse on Case (before update) {
set<Id> parentIds = new set<Id>();
map<Id,EmailMessage> mapEmailMessage = new map<Id,EmailMessage>();
for(Case c:trigger.new){
parentIds.add(c.Id);
}
list<EmailMessage> lste = [select id,HtmlBody,parentId from EmailMessage where parentid in:parentIds and Incoming = true];
if(lste.size() > 0 ){
for(EmailMessage e:lste){
mapEmailMessage.put(e.parentId,e);
}
list<Case> lstC = new list<Case>();
for(Case c:trigger.new){
if(mapEmailMessage != null && mapEmailMessage.get(c.Id) != null)
c.description__c = mapEmailMessage.get(c.Id).HtmlBody;
}
}
}
Plz help me.
Sample Email Content:
Hi this is google image and below image screen shot
What Salesforce functionality happen here is by defualt email text will be populated to description field and screen shot will get stored into attachments. and under case object we do have Emails related list where we can see original email content which customer has sent.
But the problem is my customer wants to see original content which customers has sent with in the description field .
So I have created one custom description field and datatype is Rich text area.
Customization i have done :
Created workflow rule on EmailMessage Object and tried to populate EmailMessage object HtmlBody field into Case object description (Custome field ) .
text is populated but images are not able to see and some empty textboxes i can see like below.
So above solution is not working and again i have done some tirgger on EmailMessage object to update htmlbody into desc field
like below :
first i put event after insert only but still its doesnt work for me so again i put all the events but no luck.
trigger UpdateDescTrigger on EmailMessage (after insert,after update,before insert ,before update) {
//set<id> CaseIds = new set<Id>();
map<Id,EmailMessage> MapEmailMessage = new map<Id,EmailMessage>();
for(EmailMessage e:trigger.new){
MapEmailMessage.put(e.ParentId,e);
}
list<Case> lstC = [select Id,Description__c from Case where id in:MapEmailMessage.keyset()];
for(Case c:lstC){
if(MapEmailMessage != null && MapEmailMessage.get(c.Id) != null )
c.Description__c = MapEmailMessage.get(c.Id).HtmlBody;
}
update lstC;
}
My question is : i want to automatically update HTMLBody of EmailMessage into Case Description__c (Custom field)
But if i edit case record manually and saved its working for me when i have done below trigger.
trigger updateCasse on Case (before update) {
set<Id> parentIds = new set<Id>();
map<Id,EmailMessage> mapEmailMessage = new map<Id,EmailMessage>();
for(Case c:trigger.new){
parentIds.add(c.Id);
}
list<EmailMessage> lste = [select id,HtmlBody,parentId from EmailMessage where parentid in:parentIds and Incoming = true];
if(lste.size() > 0 ){
for(EmailMessage e:lste){
mapEmailMessage.put(e.parentId,e);
}
list<Case> lstC = new list<Case>();
for(Case c:trigger.new){
if(mapEmailMessage != null && mapEmailMessage.get(c.Id) != null)
c.description__c = mapEmailMessage.get(c.Id).HtmlBody;
}
}
}
Plz help me.
Try debugging the code and see what's happening and try below code,I have made slight changes to it
There is no use by creating new list ,I tried your code also but no luck .
But Case trigger is working when I edit case manually and saves the record it is updating EmailMessage Htmlbody into case description (Custom field).
What else i can do here.
I have raise a case for salesforce.com support and they also looking into this past 2 weeks.
Thanks for your replay.
Please let me know if you ever found a solution.
Thanks,
Kevin