cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PhilFancy
Advocate I
Advocate I

SharePoint News to Teams - How to ensure just one run per News?

Hi,

 

I have several flows being triggered by SharePoint News and posting to Teams channel when a news was published. 

Trigger: SharePoint: When file is created or modified in SitePages
with trigger condition @equals(triggerBody()?['PromotedState'], 2)

 

This works great and runs only for news and not for regular pages. 

 

The trigger "created or modified" is necessary because some news are posted as news directly, others become news from existing regular pages. 

 

The problem:

If someone posts a news the flow works as expected and posts to Teams. But if the user tries to correct a typo 3 mins afterwards the flow starts a second time. 

 

Does anyone see a way how to avoid a flow being started for an item a second time after it was started once? 
I just can imagine creating a "flows that ran" list that gets filled with the item IDs that already had a Teams post and check this every run to avoid doing a second post in Teams for one news. 

 

Am looking forward to hearing your ideas! 

 

Phil

 

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Super User
Super User

Hi @PhilFancy,

 

You could add a boolean field to the site pages library. When you post the first message to teams you could set that column to yes. In your trigger condition you could check if that field isn't set to yes.


Below is an example of that approach.

 

1. Create a SentToTeams boolean field in the Site Page Library.

 

senttoteamsboolean.png

 

2. Modify your trigger condition expression and include the check for the SentToTeams field.

 

@and(equals(triggerBody()?['PromotedState'], 2), not(equals(triggerOutputs()?['body/SentToTeams'], 'Yes')))

 

 

3. Add an update file properties action. Make sure you set the SentToTeams value to Yes.

 

updatesenttoteamsproperty.png



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


View solution in original post

2 REPLIES 2
Expiscornovus
Super User
Super User

Hi @PhilFancy,

 

You could add a boolean field to the site pages library. When you post the first message to teams you could set that column to yes. In your trigger condition you could check if that field isn't set to yes.


Below is an example of that approach.

 

1. Create a SentToTeams boolean field in the Site Page Library.

 

senttoteamsboolean.png

 

2. Modify your trigger condition expression and include the check for the SentToTeams field.

 

@and(equals(triggerBody()?['PromotedState'], 2), not(equals(triggerOutputs()?['body/SentToTeams'], 'Yes')))

 

 

3. Add an update file properties action. Make sure you set the SentToTeams value to Yes.

 

updatesenttoteamsproperty.png



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Hi @Expiscornovus 

 

Thank you for that great approach - I am confused I did not see this as a possible solution *facepalm* 🙂

 

The approach worked like a charm but needed to do a little change!

 

First I used a boolean column as recommended and used your trigger condition. It kept shooting Teams messages.

@and(equals(triggerBody()?['PromotedState'], 2), not(equals(triggerOutputs()?['body/SentToTeams'], 'Yes')))


So I tried 'True' instead of 'Yes', but with no success. The flows keep starting.

@and(equals(triggerBody()?['PromotedState'], 2), not(equals(triggerOutputs()?['body/SentToTeams'], 'True')))

 

So in the end I created a new single line of text column "TeamsInfo" and just put a 1 in there when the flow ran. This is what worked great. This is the condition working for me:

 

@and(equals(triggerBody()?['PromotedState'], 2), not(equals(triggerOutputs()?['body/TeamsInfo'], '1')))

 

Thank you for your help and for this great approach. Will add this to all of our News-To-Teams-Flows! 

 

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (5,828)