cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Flow trigger to take action ONLY when status is changed

I think this is not possible, but want to be sure.  I want the following to occur:

 

-a specific column (Status) is changed to a specific value (Accepted) in my SP List

-It triggers an email notification to a user email

-It ONLY triggers this email when the status is changed to Accepted, not when other fields are updated (even tho the status is still Accepted)

 

I will have more than one (one for each Status) but right now, want to get this one working before I start rolling out to the rest...

 

Any ideas on how to make this happen as described?

 

Thanks!

Carole

6 REPLIES 6
kdavis91
Continued Contributor
Continued Contributor

Hello Carole,

 

Full disclosure: I was not able to get this to work myself; and my day job has gotten busy to the point that I can't really troubleshoot it anymore. But I think this should point you in the right direction, as I'm pretty sure the logic is sound. Maybe @ScottShearer , @Jcook , or another superuser would be able to be more specific, or point out what I'm missing here.

 

 

I think it is possible, you just might have to add a column to your SP list.

 

The issue with just creating a single trigger criteria to check "Status" for "Accepted" is that any subsequent changes to an item already set to "Accepted" will also return as true and trigger the flow to send the notification email.

 

If you create a new column in the list that stores a flag indicating whether or not the item has been marked "Accepted" already (I used a Yes/No column called "Already Accepted"; and set it to have a default value of "No"), you can add a second criteria in the trigger to make sure that the Item has not previously been set to "Accepted". So, the two trigger conditions are:

 

@equals(triggerBody()?['Status']?['value'],'Accepted') - Makes sure that the Status column value is "Accepted"

and

@equals(triggerBody()?['Already Accepted?'],false) - Makes sure that this is the first time that the Status Column value is "Accepted" (Yes/No columns have Boolean values, so Yes=True and No=False)

 

Then, as part of the flow itself, you update the item to set the "Already Accepted" to "Yes". Thus, the first time that the item's status is updated to "Accepted" will be the only time that the Flow will trigger for that item. Any change before the item is set as "Accepted", the criteria for the first trigger will not be met; and any change after the flow runs and the "Already Accepted" column is changed to "Yes", the criteria for the second trigger will not be met.

 

Here is are some screenshots from what I did:

 

To set the Trigger Criteria:Trigger Criteria1.png

 

 

 

Updating the Sharepoint Item:

Pull all other dynamic content from the Trigger so that nothing else changes when you update the "Already Accepted" fieldPull all other dynamic content from the Trigger so that nothing else changes when you update the "Already Accepted" field

I hope this helps you in the right direction. I'm sorry that I don't have a comprehensive solution.

 

Kyle

takolota
Super User
Super User

Also if anyone wants to do something or send an email whenever the status is changed to any other value, then you can use Davis’ solution above, but for the second column just create a copy of the Status column like a column called StatusCheck. Then you can set the trigger condition to if Status does not equal StatusCheck.

 

@not(equals(triggerBody()?['Status']?['value'], triggerBody()?['StatusCheck']?['value'])

 

Then you can put whatever you want in the flow as long as you end the flow by setting StatusCheck Value = Status Value in an update action.

That will trigger whenever the Status changes, then reset so it’s ready to trigger again the next time it changes.

eliotcole
Super User
Super User

I would imagine an alternative solution could exist if versioning is enabled on the SharePoint and only going when the field in question is updated. Might try that out now, actually! 😃

 

CPVain
Frequent Visitor

Hey Carole,

 

This is totally doable, as I have many of these status dependent email flows for my sharepoints. Here's a breakdown of how to build the flow:

 

Trigger: When an item or file is modified (link to your sharepoint and specific list. If you want to limit it down to a specific view to filter the column choices, you can but not totally needed) EDIT:(as pointed out by @takolota if you want to have that limited to not include updates after it has been switched to "Accepted", then definitely follow the example provided about using a second column to help filter out unneeded flow runs)

 

If you have any other fields from the sharepoint (like text fields) that you would like to include in the email, make sure to run them through any formatting translation expressions so they don't look weird on the email.

 

Next Step is to add Condition and set the input to the dynamic content for your column. So Status for input, then Is Equal To for the check, and Accepted for the value (you can set the value to whatever for the other options you have).

 

Then on the If Yes side of Condition, I would suggest using an HTTP request connector (doesn't require you to connect your Outlook and makes it look like a system email from your Sharepoint directly).

 

If you're unfamiliar with HTTP requests, here's a simple template:

 

Site address: Your sharepoint

 

Method: POST

 

Uri: _api/SP.Utilities.Utility.SendEmail

 

Headers: (this is displayed in a table format) First key= content-type, First value = application/json;odata=nometadata, then Second key = accept, Second value= application/json;odata=nometadata

 

Body: This is where you'll have to do some parsing for the actual email itself. Here's an example screenshot of what one of my test ones looked like:

CPVain_0-1630187158177.png

HTML tags will be important for the spacing and style of the actual "body" of the email. So the To section will be who you send the email to (sadly couldn't make it CC anyone, but no big deal). The Body is the body of the email. and Subject is the email subject.

 

Hope this helps! Let me know if something weird happens.

CPVain, doesn’t that trigger every time something is modified and doesn’t limit it to when the status changes?

 

The point of using trigger conditions on a second column or some other versioning set-up here is that it limits flow runs to just when the status is changed.

Depending on license, people only get a set number of actions every day, so using a regular condition here without trigger conditions means you’re using like 10x the number of actions per day for the same flow.

CPVain
Frequent Visitor

Thanks for pointing that out and I edited my response on the trigger portion. My usual assumption when statuses are changed to Accepted or some kind of "finished" status, then the item is either moved to a non-default view or sent to a database to be stored and the list item deleted (at least that's how I set lists up, nothing worse than a lagging list when the item limit gets full).

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events happening this month - don't miss out!

 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Users online (4,737)