How to send reports to different recipients based on the date

Reposted from https://www.sqlmessenger.com/docreader.html?id=559

Q: I have a duty engineer roster like the one below. I want to send some alert messages to the engineer on duty for each day based on the date. For example, send alert emails to…


This content originally appeared on DEV Community and was authored by AndySqlman

Reposted from https://www.sqlmessenger.com/docreader.html?id=559

Q: I have a duty engineer roster like the one below. I want to send some alert messages to the engineer on duty for each day based on the date. For example, send alert emails to Liam on Monday, to Noah on Tuesday, and so on. How should I configure this?

Image description

A: You can use the "Variable Recipient" of SQLMessenger to accomplish this task.

Here we use SQL Server database to demonstrate. If the roster is stored in a different type of database, then the query statement for the variable needs to be modified.

Step 1: Create a variable named "SendTo" for the task.

Image description

The value source the variable is "Read from database". The SQL statement for the variable as follows:

select email from roster where week_day = DATENAME(weekday, getdate());

Step 2: Select the variable "SendTo" created in the previous step as the recipient for the task.

Image description

When the system executes this task, it will use the SQL query of the variable to look up the email address of the engineer on duty for the day in your roster table and send the email to that address.

Image description

You can also use this method to send reports to members of your Slack workspace.

Tip: This method requires configuring the Slack App in SQLMessenger first.

  • First, add a column named "slack_member_id" to the roster table to store each engineer's Slack Member ID.

Image description

  • Then, create a variable named "MemberID" in the task, and use it to query the Slack Member ID of the on-duty engineer for the current day from the roster table.

Image description

  • In the "Select Recipients" dialog, navigate to the "Send Via Slack" tab and select the variable "MemberID" as the Slack recipient for the task.

Alert list sent to the on-duty engineer via Slack by the task:

Image description

Note: To ensure the email body retains its formatting, we use SQLMessenger's format conversion feature to convert it to PDF before sending it to the Slack recipient.

Image description


This content originally appeared on DEV Community and was authored by AndySqlman


Print Share Comment Cite Upload Translate Updates
APA

AndySqlman | Sciencx (2024-09-06T00:17:31+00:00) How to send reports to different recipients based on the date. Retrieved from https://www.scien.cx/2024/09/06/how-to-send-reports-to-different-recipients-based-on-the-date/

MLA
" » How to send reports to different recipients based on the date." AndySqlman | Sciencx - Friday September 6, 2024, https://www.scien.cx/2024/09/06/how-to-send-reports-to-different-recipients-based-on-the-date/
HARVARD
AndySqlman | Sciencx Friday September 6, 2024 » How to send reports to different recipients based on the date., viewed ,<https://www.scien.cx/2024/09/06/how-to-send-reports-to-different-recipients-based-on-the-date/>
VANCOUVER
AndySqlman | Sciencx - » How to send reports to different recipients based on the date. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/09/06/how-to-send-reports-to-different-recipients-based-on-the-date/
CHICAGO
" » How to send reports to different recipients based on the date." AndySqlman | Sciencx - Accessed . https://www.scien.cx/2024/09/06/how-to-send-reports-to-different-recipients-based-on-the-date/
IEEE
" » How to send reports to different recipients based on the date." AndySqlman | Sciencx [Online]. Available: https://www.scien.cx/2024/09/06/how-to-send-reports-to-different-recipients-based-on-the-date/. [Accessed: ]
rf:citation
» How to send reports to different recipients based on the date | AndySqlman | Sciencx | https://www.scien.cx/2024/09/06/how-to-send-reports-to-different-recipients-based-on-the-date/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.