What is achieved in this Flow?
- Run the Flow periodically on a schedule or on some other Trigger as per your choice.
- Query a SharePoint List and GetItems (multiple rows)
- Create an HTML Table format with specific fields to be sent in a mail.
- If the Output is Empty, Do not send mail, else send mail to specific recipients.
Steps
- I am triggering this Flow on 'Recurrence Schedule' Trigger.
- Getting Items from a SPO List only where the column 'Status' eq 'Request Placed' [ So I am doing OData Filter Query and getting only specific rows from a possibly large SPO List ]
- Next step is the 'Data Operations Select' Action. [ This will take input Only from an Array Output ]
- As the 'Get Items' Output is in Array, 'Select' action works great. The output 'Value' from 'Get Items' will be the Input of 'Select'
- 'Map' I am entering the headings of the Table and their values from output of previous steps which will be only those items where 'Status' field value is 'Request Placed'
- Next step is put the output of 'Select' Action to String, coz HTML Table action will not take an Array value as Input. so we need to use 'Data operations - compose' Action and put the output of 'Select' in Compose action
- Next Add 'Create HTML Table' Action -> Output will be from the 'Compose' step. (by default headers are created in HTML table action Advanced options)
- Next I am checking a Condition output is blank (this can be done for any step, it was just easy for me to enter the select output), I wanted to send separate emails if blank and if not blank. So instead of "@empty(body('Select'))" it could also be "@empty(body('Compose')) or "@empty(body('Get_Items'))"
After checking the Condition, I am sending different mails when the condition is True and False. If the condition is False, the output from 'Create HTML table' will be sent in body of the Mail.