Using Trigger conditions save the API calls of Flow.
- K DINESH
- Sep 6, 2020
- 2 min read
Scenario :- Trigger a flow when an item is created in SharePoint which includes attachment only .
According to the Microsoft official documentation users having Power Automate for office 365/Power Automate per user Plan/ Power Automate per flow Plan will see the difference in API calls.

Usually to achieve this scenario we will create a flow structure like this :-
When an item is created -> Condition -> based on the condition will instruct flow to proceed further.
If you notice this sample flow it will trigger every time an item is created in SharePoint whether that item includes Attachment or not.
Today we are going to learn Trigger a flow only if item contains attachment. Using the Trigger conditions you can save API requests.
Step 1 :-
Login to the Flow using your work or school account. Click on My flows -> Click on New -> select Automated from blank -> give the flow name -> Choose when an item is created (SharePoint trigger).

Step 2 :-
Add Compose and go to the expression and paste this code.
if(triggerBody()?['{HasAttachments}'],true,false)
It will return the value as True if item contains attachment and it returns False if there is no attachment.

Step 3 :-
Now copy this Expression from the Compose and click on Trigger (…) three dots click on the Settings. In the Trigger conditions Click on + and paste this code.
Note that if you simply paste this code and save the flow then it will throw the below error message :-

To avoid this make sure to add the @before the expression. So you have to paste the below code.
@ if(triggerBody()?['{HasAttachments}'],true,false).
You can try with multiple expressions to save the API calls.

Now you can remove the Compose we have added it just to write the expression.
Step 4 :-
Add Send an email action card.

Step 5 :-
Now test the flow. It will trigger only when an item is created that includes attachment only.

Using the Trigger Conditions you can save the API calls of Flow.
Hope you like this post 😊😊!!!
Please do like, Share and subscribe to get notified on latest posts.👍👍👍 !!!
Comments