I want to create a custom logic that will copy the value of EmailMessage.Subject
after the merge fields used in it get resolved.
I tried to do it on the after insert
trigger on EmailMessage
object. However, it turns out that the merge fields used in Subject field are not always resolved before after insert
trigger execution. Is it a normal behavior? Should I use a flow for this case instead?
Lightning Email Template configuration:
Here is how the email is send using Case.SendEmail action:
Here is the received email (don't look at the yellow part as it is automatically appended to email subject in the after insert
trigger, it's not a merge field that is used in the email):
What I want to achieve? I want to save in some field on the Case object the latest email subject which is related to this case.
afterInsert
but are resolved in the body? Are you sure the merge fields are properly formed?after insert
trigger the email subject contains merge fields but they are not resolved yet, and the custom logic used there makes such an assignment:case.Customer_s_Latest_Email_Subject__c
=emailThatFiredTrigger.Subject