Welcome to the "Pushing the Limits" series, where we find different ways to maximize the functionalities of Dynamics 365 to solve unique problems!
In this article, we are focusing on setting up a queried cron job that will automatically send out emails to Contacts who have abandoned their item-filled shopping carts on the portal. These emails will encourage order completions as they remind the Contacts to finish checking out the products. Let’s take a look at how to set this up:
1. If it does not exist already, create a new field on the cart entity called ‘Email Reminder Sent’
This will be a Yes/No option field. The purpose of this field is that the System will use it to recognize Cart entities that have had reminder emails sent out or not.
2. Create a Workflow that will send out via a Queried Cron Job that sends out an email reminding someone they still have an open cart and then marks the cart as Email Reminder Sent = Yes
Navigate to Advanced Settings > Processes to create a new Workflow
Set up the workflow to the following:
For the Send Email step, click on Set Properties to create the Email template that will be used as the Reminder Email. Here is an example:
For the Update Cart step, click on Set Properties to and select the Email Reminder Sent field to Yes. This will update the Email Reminder Sent field to Yes when the workflow executes:
Note: Please check out this Workflow article for more details if needed.
3. Create a Queried Cron Job where the query looks for open carts that were created yesterday and Email Reminder Sent = No
- Set the fields to the following:
- Name: AbandonedCartEmail
- Type: Queried
- Instances Are Unique: No
- Workflow for Query: Select the workflow created in Step 2
- Trigger Interval: Blank
- Expression: 0 12 * * * (runs everyday at 12pm)
- Process: Blank
- Entity Target: cobalt_cart (or the correct schema name for the Cart entity in your system)
- Then click on View Query from the top ribbon and setup the query to the following:
- Created On = Yesterday
- Email Reminder Send = No
- Status Reason = Active
Save and close the query and the queried cron job when done.
Note: Please check out this Queried Cron Job article for more details if needed.
4. Once the Queried Cron Job is setup and active, confirm it works by checking if the Email Reminders have been sent
Cart records will be created for Contacts when they add an item from the Portal shop to their cart.
The query from the cron job will look for Carts that were created yesterday and have Email Reminder Sent = No.
The system will identify these abandoned Carts from yesterday and the workflow that we created will automatically send Emails to the Contacts who have not completed their purchases.
Once the email reminder has been sent, the Email Reminder Sent field will update to Yes, so the Contacts do not receive duplicate emails moving forward.