How to mention multiple users in teams message without using loops?
Use Case
One of the common scenarios is to mention multiple uses while posting teams message using power automate. For multiple mentioning, we need to perform the following steps:
- Iterate on each user
- Get individual mention token
- Append each mention token in a variable
In this tutorial, we will generate mentioning token for multiple users without using loops or Apply to each action.
Scenario
A custom task list in SharePoint where “Assigned To” is a multi-select user field that stores the user(s) responsible for updating/completing a task. We will design a schedule flow that reminds the owners by posting a message on team & mentioning (@ the specific user) to take the action.
Solution
1. Configure the scheduled flow with daily reminders. Set the time zone, start time etc. as per the need:
2. Next, add “Get items” action to get the list items from task list. Use filter query to filter the items for which reminders need to be send on MS teams channel:
Status eq 'In Progress'
3. Add “Select” action to choose “Assigned to” column from the output value object of “Get items” action. The flow will automatically add “Apply to each” action when you pass “Assigned To” column in ‘From’ parameter of Select action:
Click “Switch Map to text mode” button:
Enter the below expression in the Map textbox. Expression needs to be entered in the expression box as shown below:
concat('<at>',item()?['Email'],'</at>')
Lastly, add “Post message in a chat or channel” action to post reminder message. Choose teams, channel details and combine the output of select action to mention multiple users in the message:
join(body('Select'),' ')
Output
Conclusion
With the help of “Select” action & expressions, it is possible to generate mention token for multiple users without loop (or Apply to each action). The above example uses the markup to mention users in the teams message.