I have email to case implemented However I want that if a case status is resolved and email is sent to same ref id then instead of having that email attached to same previous case , a new case is created.
I tried this implementing using a trigger however realized that email parent id is read only and I cant assign a new case id to it.
Best Answer
If a new
EmailMessage
comes in for a Case whose status is Resolved, and you wish instead to create a new Case, then:The
EmailMessage
afterInsert trigger does the following:Case.ParentId
to the previously-closed case)EmailMessage
withEmailMessage.ParentId
pointing at the just-created CaseIf the incoming
EmailMessage
has Attachments, then those Attachments will have to be moved through insertion/deletion using an afterInsert trigger onAttachment
. Such trigger would look to see if its ParentId was to a resolved case and then would need to locate the newly-created Case, perhaps through the old Case -> new Case child relationship (pick most recent)This is all tricky because the attachment is added after the EmailMessage is inserted on the original Case