Let's try to create Power Automate connected to SQL Server for sending Leave Approval Email using Low code together.

Let's try to create Power Automate connected to SQL Server for sending Leave Approval Email using Low code together.

Let's try to create Power Automate connected to SQL Server for sending Leave Approval Email using Low code together.

Hello everyone! I’ve been away for a long time from blogging due to various events that have kept me busy, making it challenging to find time for writing. In my latest article, I briefly introduced Power Automate. Today, I’d like to try creating a simple Flow so that everyone can see how it can be practically used.

Prerequisites

  • You should have an account with a subscription that allows you to use the Power Automate service, such as Microsoft O365 E1, E3, E5 subscriptions, and similar.
  • In case you don’t have a subscription, the minimum cost for using Microsoft Power Automate is $15 per user (subscription) or $0.6 per flow run (pay as you go).
  • You should have a SQL Server in the cloud for testing purposes.

Objective: We are going to create a Flow that will send a Leave Approval Email only when new data is added to the table in SQL Server.

  1. First, let’s create a table to use on SQL Server:
CREATE TABLE Example_Leaves
(
  LeaveID INT NOT NULL IDENTITY PRIMARY KEY,
  Requestor NVARCHAR(100) NOT NULL,
  RequestDate DATE NOT NULL,
  SubmittedDate DATETIME NOT NULL,
  LeaveDetails NVARCHAR(MAX),
  IsApproved BIT NOT NULL DEFAULT 0
);

Note: In this example, the Requestor field will store the requestor”s email.

  1. Next, go to https://make.powerautomate.com/ and click on “Create” in the left panel.

  2. Choose “Automated cloud flow” and select “When an item is created (V2) SQL Server” as the trigger.

    • Once the “Example Leave Request” flow is created, enter the connection details for your SQL Server and click “Create connection.”
    • After the SQL Server connection is created, you will see the Server name, Database name, and Table name. Create Power Automated Flow
  3. Once the “Example Leave Request” flow is created, enter the connection details for your SQL Server and click “Create connection.” Create SQL Connection in Flow

    After the SQL Server connection is created, you will see the Server name, Database name, and Table name. Choose SQL Connection in Flow

  4. Click the ”+ New Step” button and select “Start and wait for an approval.” Fill in the Approval type, Title, Assigned To, and Requestor, as shown in the example below.

    Note: In this case, I selected “Approve/Reject — First to respond” as the Approval type, which means anyone can approve/reject the request in the Assigned To field.

    Create the approval process in Flow

  5. Click the ”+ New Step” button and select “Condition.” Then, select the Outcome in the “Choose a value” field to compare it with “Approve.” Check condition outcome process in Flow

  6. In the “If yes” section, choose “Update row (V2)” for SQL Server to update the row and set the IsApproved field to true. Update row in SQL Server

    Note: Do the same in the “If no” section, but set IsApproved = false.

  7. After the “Update row (V2)” action, select “Send an email (V2)” from Office 365 Email to send an email confirming the approval details to the Requestor. Send an update notification service

  8. Done! 🥳 Overall of workflow processes

Once you’ve created the Flow, let’s trigger it to see how it works.

  1. Insert some data directly into the SQL Server table:
INSERT INTO [dbo].[Example_Leaves] (Requestor, RequestDate, SubmittedDate, LeaveDetails)
VALUES ('{your-email}', '{your-request-date}', GETDATE(), '{your-request-detail}');

Select row in table on SQL Server

  1. After inserting data into the table, let’s check the Flow to see if it starts running. In the image below, we can see that there is one flow with Status = Running. Note:

    • The Flow may take a short delay before triggering.
    • Status = Running until the Approver approves/rejects the request. Power Automated workflow details
  2. Now, let’s check our Inbox to see if we received the Approval email. The Approval Email will look like the image below, allowing you to Approve/Reject the request. Approval an email and success notification

  3. Let’s check if the IsApproved value in the table changes after we click “Approved” in the email and if the approval confirmation email is sent back to the Requestor. Ta-daaa! It works perfectly! 😄 Approved an email and update row

That’s it! For anyone interested in using Power Automate for simple applications, I hope this will be helpful. But before you use it, please study both the advantages and disadvantages of Power Automate. See you next time! 👋


P.S. Lastly, if anyone is interested in reading more about the technology of Mycos Company, you can follow and read further content on their Medium page at https://medium.com/mycostech


Mycos is a software consulting company in Chiang Mai, Thailand specializing in all things Microsoft

Related Posts

Let's check our site's accessibility easily using 'Accessibility Insights for Web' on Microsoft Edge.

Let's check our site's accessibility easily using 'Accessibility Insights for Web' on Microsoft Edge.

Hello to all the readers who have come across this article. Lately, I've been quite busy and it's taken me a while to find some free time to write on Medium. Today, I want to share some knowledge tha

read more
Conditional Formatting (Fx) in PowerBI Custom Visual

Conditional Formatting (Fx) in PowerBI Custom Visual

👋 Hi Everyone 👋 During this time, I have a chance to implement the PowerBI Custom Visual with my team. And we spent a lot of time researching the conditional formatting (Fx) and we found many inter

read more
An Introduction to Microsoft's Power Automate

An Introduction to Microsoft's Power Automate

Today, we're introducing Microsoft's Power Automate, formerly known as Microsoft Flow. If you're familiar with Microsoft Power Platform services such as Dynamics 365, SharePoint, Power Apps, PowerBI,

read more
Pass Through Data Over IServiceProvider.CreateScope()

Pass Through Data Over IServiceProvider.CreateScope()

[ASP.NET] In some cases you may encounter the situation that you need to pass through some particular data over a new scope of Service Provider.For instance, when you implement a solution that inte

read more
Write Unit Tests for React Hooks using react-hooks-testing-library

Write Unit Tests for React Hooks using react-hooks-testing-library

Hooks in React are a feature that has drastically changed the way we write React. It's like undergoing plastic surgery in Korea, where some developers love the new look, while others prefer the old o

read more
Scan code with Credential Scanner on Azure DevOps

Scan code with Credential Scanner on Azure DevOps

🥳 Happy New Year 2023! 🥳Wishing everyone a great year ahead!Now, let's get down to business. Today, I'm going to introduce you to a handy tool that checks for leaked passwords, secrets, certifi

read more
Easy way to check user’s permission on SharePoint Online site in the web part

Easy way to check user’s permission on SharePoint Online site in the web part

Hello Everyone! 🎉 Happy New Year 2021 🎉 I hope you have a wonderful holiday, good vibes, and a nice party 🍻. This blog is the 2nd content which’s I write in English. In the previous blog, I explai

read more
SharePoint Group & Permission levels in SharePoint Online

SharePoint Group & Permission levels in SharePoint Online

Hello everyone 👋 !!! This is the 1st time that I wrote the SharePoint Online blog in English. This blog explains permission levels in SharePoint Online. Once you create a new site in SharePoint Onli

read more
Speed up and make your SPFx reloads quick and easy with the SPFx-Fast-Serve tool.

Speed up and make your SPFx reloads quick and easy with the SPFx-Fast-Serve tool.

Hello everyone! I'm back! In the past period, I've been busy expanding my knowledge, reading some Microsoft Learning materials, trying out new things, and handling various tasks, which left me with l

read more
What is SharePoint? How does it work? Let's take a look together! 😆

What is SharePoint? How does it work? Let's take a look together! 😆

Hello everyone who stumbled upon and is reading this content. After spending a considerable time exploring various content on Medium, I wanted to share a little bit of my knowledge. Having delved int

read more