Email-to-Flow, let’s move some email

Email-to-Flow is available on the Salesforce Appexchange.

If you haven’t taken a peek at Introducing Email-To-Flow, a low-code Email Service – Sproket Logic, please do. It won’t bite.

Hey there. I love the Email-to-Flow concept. I’m just not ready to make the leap of replacing my Email-to-Case with Email-to-Flow. Can I still leverage some its core functionality?

Absolutely. The apex actions can be leveraged when and where it’s required. What’s your requirement?

We are using Email-to-Case. We have post processing flow logic for Closed cases. If the case is closed, we create a new case. The problem is, we also want to move the email message and attachments to the new case as well.

Gotcha. Obviously, we would recommend that you leverage Email-to-Flow instead. With Email-to-Flow, routing emails based on a closed case is a piece of cake. That being said, we can also help if you are not ready to fully commit. Introducing the Move Email Messages apex action.

Let’s take a peek under the hood.

InputDescription
Existing Email Message IdThe record id of the existing Email Message
to be moved.
New Case IdThe record id of the case in which the
Email Message should be moved to
OutputDescription
New Email Message IdThe record id of the newly created Email Message
is SuccessThe execution status of the apex action. If True, the process was successful. If False, an error was encountered.
Error Message The error message encountered when the is Success values is set to False.

Cool. What can I expect from this apex action?

If you have every worked with Email Messages and their related Attachments/Files, you know Salesforce has a whole range of limitations regarding reparenting these records. The task is not impossible. It’s just makes for a longer trip.

The Move Email Messages apex action:

(1) Clones the existing Email Messages, reparenting the link to case Id provided

(2) Clones any Attachment record(s), reparenting the link(s) to the new Email Message record.

(3) Clones any ContentDocumentLink record(s), reparenting the link(s) to the New Email Message record

(4) Deletes the original Email Message, Attachment(s), and ContentDocumentLink(s)

NOTE: This operating can impact and embedded links in your email body. Please review to ensure that impact is acceptable to your organization.

NOTE 2: Once the email message is moved, you may have a situation in which the header reference id now points to two cases. Be sure your process properly handles this situation.