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
Solved! Go to Solution.
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.
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.
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.
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.
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!
User | Count |
---|---|
6 | |
5 | |
3 | |
3 | |
2 |