Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Send messages to microsoft teams user via power apps button

(0) ShareShare
ReportReport
Posted on by 69

Hi everyone,

I am new in Power Apps, I need your help please.

Scenario:

  1. SharePoint list connect to power apps
  2. The item creator column/field is generated automatically through Microsoft 365 User (also connected to Power Apps)

My wish

1. Use a button

  1. Submit form
  2. Send a message to the item creator  via MS Teams Chat/Message
  3. Message body:
    1. Text: “A new item has been created with the following details”
    2. Content of field1 (Text)
    3. Content of field2 (number)
    4. Content of a field3 (number – calculated)
    5. Content of field4 (dropdown selected value)


I have been trying to this out: 

SubmitForm(Form1);
MicrosoftTeams.CreateChat(

DataCardValue1.Selected.Email, {

content: Concatenate(

"A new item has been created with the following details: ", RecordGallery1.'Nr.' & RecordGallery1.Selected.'Country' & RecordGallery1.Selected.'Customer' & RecordGallery1.Selected.'Weight' & " is completed."

),

contentType: 0

}

)


SubmitForm(Form1);
MicrosoftTeams.CreateChat(

DataCardValue1.Selected.Email, {

content: Concatenate(

"A new item has been created with the following details: ", RecordGallery1.'Nr.' & RecordGallery1.Selected.'Country' & RecordGallery1.Selected.'Customer' & RecordGallery1.Selected.'Weight' & " is completed"

),

contentType: 0

}

)

 

Please any help or suggestion is appreciated @WarrenBelz

  • konnann Profile Picture
    konnann 2 on at
    Re: Send messages to microsoft teams user via power apps button

    This is not working for me, is there anything special that needs to be configured between PowerApps and Teams?

  • Motion Profile Picture
    Motion 69 on at
    Re: Send messages to microsoft teams user via power apps button

    Thanks so much @Anchov 

     

    I am getting error but I would use the power automate solution . I appreciate your effort.  Thanks once again.

  • Verified answer
    Anchov Profile Picture
    Anchov 1,984 on at
    Re: Send messages to microsoft teams user via power apps button

    Ok a few things that I see:

    1. When you select an item RecordGallery1, a variable is getting created that stores your selected record.  Whenever you save this record, you want to update this variable so you get the most current results in the variable. The best place to do this would be in the OnSuccess property of you form and the formula to update would look like something like this:

     

     

    UpdateContext({CurrentItem: Self.LastSubmit})

     

     

    It looks like you are using the new Microsoft canvas app template (auto generation of an app), so this is already likely there.

    2. In your custom button, I don't think your need to perform another SubmitForm(Form1) action, as you are already submitting the  icon in your form and this seems redundant from what I see. I would remove this.

    Anchov_0-1705072263394.png

    3. Since you are already saving the newest record information in the CurrentItem Variable, you will want to use this variable instead of trying to reference your gallery selected item. So you would re-write your Team Chat formula to something like:

     

     

    MicrosoftTeams.CreateChat(
    //Not sure if DataCarValue1.Selected.Email is in relation to your form, but assuming your have a Column called Email in your SharePoint list, this is what you use. If not it might be something like CurrentItem.PersonField.Email
    CurrentItem.Email, {
    
    content: Concatenate(
    "A new item has been created with the following details: ", CurrentItem.'Nr.' & CurrentItem.'Country' & CurrentItem.'Customer' & CurrentItem.'Weight' & " is completed."
    
    ),
    contentType: 0
    }
    )

     

     

    I tried testing this, but I was not able to get a teams message sent in my environment (but no error). If you have no luck with this, you might try using power automate, see this thread:
    Solved: Powerapp create Microsoft team chat - Power Platform Community

    Another option:
    Microsoft Teams messages from Power Apps - 365 Corner

    Edit:

    I did get the Create Chat to work, but I had to use this syntax:

    MicrosoftTeams.CreateChat("AdeleV@0v42t.onmicrosoft.com", {topic: $"topic: {CurrentItem.Coat}"})

    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

    Cheers!
    Rick Hurt

  • Motion Profile Picture
    Motion 69 on at
    Re: Send messages to microsoft teams user via power apps button

    "RecordGallery1" is the Gallery that populates the items in the sharepoin list and shows items when selected.

    OnSelect:
    
    UpdateContext({ itemSelected: true, CurrentItem: ThisItem })
    
    Item:
    
    If(IsBlank(SearchInput1.Text), 
     Demo, 
     Filter(Demo, 
     Or(StartsWith(Nr.,SearchInput1.Text), StartsWith(Customer, SearchInput1), StartsWith(Land.Value, SearchInput1))))
    


    The button is located outside the form and outside the gallery . The button is meant to be used for the final submission 

    the Icon check is used for saving and submitting the form (inbetween: thats is during filling of form, if the whole fields are not yet filled ) .

    Thanks for your help




  • Anchov Profile Picture
    Anchov 1,984 on at
    Re: Send messages to microsoft teams user via power apps button

    For clarification, "Record1Gallery1" is different that the gallery name you have in your script "RecordGallery1".  

    How is RecordGallery1 being populated? Is this gallery related to your form at all?  Where is the button located, is it in the gallery or out side the gallery?

  • Motion Profile Picture
    Motion 69 on at
    Re: Send messages to microsoft teams user via power apps button

    Hi @Anchov ,

     

    The  

    RecordGallery1.'Nr.' & RecordGallery1.Selected.'Country' & RecordGallery1.Selected.'Customer' & RecordGallery1.Selected.'Weight' & " is completed

    part show error : "Name isn't valid. Record1Gallery1 isn't recogniszed". 

    I think the problem is the concatenation. It cant excute or run that part. Thanks

  • Anchov Profile Picture
    Anchov 1,984 on at
    Re: Send messages to microsoft teams user via power apps button

    What specific issue are you encountering? Is the chat not posting, or is it posting, but the values you expect are not appearing? Are you receiving any error messages? My hunch is that you are submitting your form successfully, and then the form is getting reset, causing your expected values that you want to appear in the chat to get nulled out. Any additional information or screenshots would be helpful.


    If I have answered your question, please mark your post as Solved.
    If you like my response, please give it a Thumbs Up.

    Cheers!
    Rick Hurt

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,495

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,822

Leaderboard