Skip to main content

Notifications

Community site session details

Community site session details

Session Id : i72H0hxa8B5GWKq0vibc8K
Power Apps - Building Power Apps
Unanswered

Open new screen to send Slack message based on selected user

Like (0) ShareShare
ReportReport
Posted on 7 Nov 2023 18:13:23 by

I'm building an app that displays a user gallery of upcoming birthdays and work anniversaries based on a SharePoint list. I've got that working just fine.

 

My next step is to have an image that functions as a button (see Screen 1 below). This button opens a new screen where the user can send a message via Slack to the selected colleague from the previous screen. There are two things I'm trying to figure out:

 

  1. How can I get the selected user's name to populate in the second screen (see Screen 2 below)?
  2. Is there a way to post a Slack DM with the user's email address instead of username? I'm pretty sure our usernames are based on our emails, but we actually use different naming conventions for different email domains. (Or maybe there's a way to pull the user's email address then remove the domain?)

 

Screen 1: 

LarissaNewton_0-1699379706930.png

Screen 2:

LarissaNewton_1-1699380548927.png

 

Current Slack formula being used in the OnSelect field of the paper airplane icon in Screen 2. I want to replace #larissa-test-channel with a dynamic value based on the selected user.

 

 

Slack.PostMessage("#larissa-test-channel", Text(TextEmailMessage1), {as_user:true})

 

 

Thanks!

Categories:
  • Community Power Platform Member Profile Picture
    on 07 Nov 2023 at 19:18:30
    Re: Open new screen to send Slack message based on selected user

    Thanks so much! I got those first two parts working great. 

     

    I'm already using a flow to generate my SharePoint list of users with birthdays listed in their Delve profile. I wonder if I could add a step using your suggestion for the Slack API, but then put their user ID in a new column of the SharePoint list. If I can manage this, then I could pull that into the app for the post message action. 

  • MudassarSZ365 Profile Picture
    591 on 07 Nov 2023 at 18:41:34
    Re: Open new screen to send Slack message based on selected user

    Hi @Anonymous 

    For getting the selected user's name on the second screen:

    On Screen 1, set the OnSelect property of the button (the image you're using) to navigate to Screen 2 and pass the selected user's information. Assuming your gallery's selected item is Gallery1.Selected, and it has a field called Name, you’d write something like this:

    Navigate(Screen2, {SelectedUserName: Gallery1.Selected.Name})

    On Screen 2, use the context variable to populate the name in the desired text label or input. You can set the Text property of the label where you want the name to show up to:

    SelectedUserName

    For sending a Slack DM using the user’s email:

    You’ll need to work with Slack’s API. It’s a bit tricky since you want to map the email to the Slack user ID or username. Here’s a general approach:

    Use a Power Automate flow to handle the Slack API interaction. In Power Apps, use the OnSelect property of the send button to call this flow, passing the email of the selected user.

    In the flow, you would have an HTTP request to Slack's users.lookupByEmail API to get the user ID associated with the email.

    Once you have the user ID, use it in another HTTP request to chat.postMessage to send a DM to that Slack user.

    In Power Apps, it would look something like this on the OnSelect property of the send button:

    PowerAutomateFlowName.Run(Gallery1.Selected.Email, TextEmailMessage1.Text)

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Building Power Apps

#1
MS.Ragavendar Profile Picture

MS.Ragavendar 32

#2
Rajkumar_M Profile Picture

Rajkumar_M 16 Super User 2025 Season 1

#3
mmbr1606 Profile Picture

mmbr1606 14 Super User 2025 Season 1

Overall leaderboard
Loading started