Power Automate: How to trigger a flow only when specific field(s) have certain values
Tags: powerautomate
Published: 2024-03-06 12:50:23

## What is Power Automate
Power Automate is a tool that helps you automate tasks and workflows across your favorite apps and services, without needing any coding skills. 

With Power Automate, you can streamline processes, integrate different apps, and automate routine tasks, so you can focus on more important things. 

Whether it's sending emails, updating spreadsheets, or triggering notifications, Power Automate makes it easy to automate everyday tasks and boost productivity.
   
## What are Power Automate Triggers?
Power Automate Triggers are like the starting points for your automated workflows. They're the events or actions that kick off a series of tasks or actions within Power Automate. Think of them as the "if this happens, then do that" moments in your workflow.

For example, a trigger could be receiving an email in your inbox, a new file being added to a folder in OneDrive, or a new tweet being posted. These triggers are what signal Power Automate to start running your automated process.

Once a trigger is activated, Power Automate can then perform a sequence of actions, like sending an email, creating a new record in a database, or updating a spreadsheet. Triggers are essential because they determine when your automation begins and what actions it should take based on certain conditions or events.
   
## How to trigger a Power Automate flow ONLY when a specific field has a certain value?
Let's say you're managing a project using a SharePoint list to keep track of tasks, deadlines, and team members. 

You want to be instantly notified whenever a task status changes to "Ready To Test" in that list. You don't want the flow to be triggered when a new item is created, or other fields are updated

With Power Automate, you can set up a trigger that activates a workflow whenever a specific column, like "Task Status," is modified in your SharePoint list.
   
### The SharePoint List
![The SharePoint List](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ee9ueu0f2i8ldntvefh.png)
   
### The Power Automate Flow

1. Create a new Flow
2. Add as Trigger "When an item is created or modified" (SharePoint Action)
3. Select your SharePoint and List Name

![Power Automate SharePoint Trigger](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l9cr0ijid7w8rd1fau1a.png)

4. Go to **Settings**
5. Add you trigger.  In our example, we check if the column **Task Status** is modified to **Ready to Test**


![Power Automate SharePoint trigger settings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/btww5qm8h1t8lvhxldmt.png)
```
@equals(triggerOutputs()?['body']['TaskStatus']?['Value'],'Ready to Test')
```
Our **Task Status** column is a choice column with 4 choices.
You can also use the ID of the choice instead of the Text
```
@equals(triggerOutputs()?['body']['TaskStatus']?['Id'],2)
```
   
## How to trigger a Power Automate flow ONLY when a 2 columns have a certain value?
In out example, let's add a column **Signed Off** which is a **Yes/No** column and we want the flow only executed when Task Status is 'Ready to Test' and Signed Off is true 

The solution is to use the **and** function
```
@and(equals(triggerOutputs()?['body']['TaskStatus']?['Id'],2),equals(triggerOutputs()?['body']['SignedOff'],true))
```

## Extras
- Instead of using the **and** function you can also use the **or** function
- This solution also work for **LookUp** and **Calculated Columns**
- In case the user creates a new item, and set the specific fields to the certain values, the flow will work as well.
- You can add more columns and make it as complex as needed