How to auto-delete e2a unmatched emails after a certain time period?
e2a Unmatched Emails
In e2a, while sending an email on the Email Service Address of an email rule, if the email does not follow the 'Action if no match found' configuration due to any possible reason, it will land in e2a Unmatched Emails queue. From the e2a Unmatched emails tab, emails can be matched to an existing record or can create a new record too, but in case the record is of no significance, users might end up deleting it manually. If the number of records is large, deleting them manually would consume a lot more time.
To save time (used in deleting unmatched emails) a configuration can be set-up using a Flow (visual flow) and a Process to auto-delete the e2a Unmatched emails after certain time period (time period for deletion can be customized as per user's requirement) of its creation date.
Setting up of emails auto-delete configuration
Configuring auto-delete for Unmatched Emails is basically a two-step process. Firstly, we need to set up a Flow to delete the record. Secondly, we need to set up a Process to call/initiate that Flow upon e2a Unmatched email record creation. Please follow the instructions/steps below to configure auto-delete for Unmatched Emails:
Step 1: Configure the Flow for e2a Unmatched Email record deletion
Firstly, we will create a new Variable to store the Id of the record to be deleted. Then a Record Delete Element would be created on this newly created Variable to delete the record. This flow would then be called by a process.
- Go to setup and search for Workflow Rules
- Setup | Create | Workflow & Approvals| Flows
- Click on New Flow button
- From the Resources tab in the left pane, double-click on Variable
- Enter a valid name for the variable ( it will hold the e2a Unmatched email id). [Example: UnmatchedEmailId]
- Set Data Type to Text
- Set Input/Output Type to Input Only
- Click Ok
- From the Palette tab in the left pane, click and drag a Decision element onto the canvas.
- Enter a valid name in the Name field of the Decision. [Example: If ID is not NULL]
- Unique Name field is auto-populated based on the value of the Name field
- Enter a valid name in the Name field of the Outcome section [Example: Id not Null]
- Unique Name field is auto-populated based on the value of the Name field
- For the Resource field click on the down-arrow option on the right, expand the Variable option and select the created variable (UnmatchedEmailID)
- Set the value of Operator field to is null
- For the Value field click on the down-arrow option on the right, expand the Global Constants option and select $GlobalConstant.False
- Set the conditions drop-downs value to All conditions must be true(AND)
- Click Ok
Please see the screenshot below of a decision:
- From the Palette tab in the left pane, click and drag a Record Delete element onto the canvas.
- Enter a valid name in the Name field of the element. [Example: Delete Unmatched Email]
- Unique Name field is auto-populated based on the value of the Name field
- For the Delete field click on the down-arrow option on the right, expand the Custom option and select ortoo_e2a__Queued_Email_Message__c (API Name for e2a Unmatched emails Object)
- Set the value of Operator field to equals
- For the Value field click on the down-arrow option on the right, expand the Variable option and select the created variable (UnmatchedEmailID
- Click Ok
Please see the screenshot below of a Record Delete Element:
- Hover over the Decision element and click on the green plus on the top-right of the element to set it as a start element
- Click and drag from the bottom diamond of the Decision element to the Record Delete element to connect both elements (See the screenshot below of how your flow would look like)
- Click on Save As
- Enter an appropriate Name for the flow [Example: Delete Unmatched Email older than x days]
- Enter Description [Example: Delete e2a Unmatched Email that is older than x days and is not moved yet]
- Set the value if the Type field to Autolaunched Flow
- Click on Ok
- Activate the Flow
Once you have configured the flow as explained above, please go for configuring a process.
Step 2: Configure the Process to call/initiate the Flow
Now we need to create a Process, which will call the (above created) Flow and pass the Id of the record which needs to be deleted. Before passing the id, we need to add a criteria to check that record Id exists.
- Go to setup and search for Workflow Rules
- Setup | Create | Workflow & Approvals| Process Builder
- Click New
- For Process Name, type Launch Flow to delete Unmatched email Record
- For The process starts when, select A record changes
- Click Save
- Click on + Add Object
- In the right window, select e2a Unmatched email from the Object drop-down list
- For Start the process select when a record is created or edited
- Click Save
- Click on Add Criteria
- For Criteria Name, set type to Id is not Null
- For Criteria for Executing Actions, keep it set to Conditions are met
- For Set Filter Conditions, click Find a field..., select Record ID and click Choose
- Set Operator to Is null, Type to Boolean and Value to False
- For Conditions, keep it set to All of the conditions are met (AND)
- Click Save
Please see the screenshot below of the criteria:
- Click Set Schedule
- Enter the time period ( x Days) After, and set the Select a date... field to CreatedDate
- Click Save
- Click Add Action in the Scheduled Actions section
- For Action Name, type Call Flow
- Click on the Flow field and select the created Flow Delete Unmatched Email older than x days
- For Set Flow Variables, click Find a field..., select UnmatchedEmailId
- Set Type to Field Reference and Value to Record ID
- Click Save
- Activate the Process
Now all the newly created unmatched emails, which follow the criteria specified in the Flow and Process would be deleted automatically.
Please contact us at support@ortooapps.com for any questions.
★★★★★ - EXCELLENT
★★★★☆ - GOOD
★★★☆☆ - OK
★★☆☆☆ - POOR
★☆☆☆☆ - RUBBISH