web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Creating a Comments wi...
Power Apps
Unanswered

Creating a Comments with people @tags in canvas apps

(0) ShareShare
ReportReport
Posted on by
Has anyone seen, created or come across a way to create a comment in a text area in which users can tag people in by adding an "at" (I can't type it here without it tagging - see image) symbol?
So that the text box detects a User() and adds them. I can't think of any way to implement this. Of course it would be easy to have a combobox with 365 users underneath and add the users outside of the text field, but that is not what my customer is looking for. 
 
Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,079 Most Valuable Professional on at
    The text box was never designed for this, so what I have is a bit of a "hack", but seems to work OK. Firstly put this OnChange of the Text Box
    UpdateContext({varText: Self.Text})
    and the Default as
    varText
    Now for the "working" part - put in a Combo Box (example is a Classic item) with the Items of
    Office365Users.SearchUserV2({searchTerm: Self.SearchText,isSearchTermRequired: false}).value
    with SearchFields whatever you want to display (Edit in the right panel) and OnChange
    UpdateContext({varText: TextInputName.Text & Self.Selected.Mail});
    Reset(TextInputName);
    Reset(Self)
    Now make the Visible of the Combo Box
    Right(TextInputName.Text, 1) = "@"
    What happens is when the user selects "@",  (do not immediiately enter anything else), the Combo Box becomes visible and allows the selection of an email address. Once this is done, it adds the address to the Variable which is the text box content, then resets the text box to include the new content. The Combo Box then resets and hides as "@" is no longer the last character.
     
    Note that if you also want to display existing records in this, you will need the Default something like
    Coalesce(
       varText,
       ThisItem.YourFieldName
    )
    and also 
    UpdateContext({varText: Blank()})
    when selecting and displaying a record (so if the content is not changed it will use the existing record field content).
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn   
     
     
  • WarrenBelz Profile Picture
    153,079 Most Valuable Professional on at
    A quick follow-up to see if you received the answer you were looking for or if you need further assistance.

    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)    Visit my blog Practical Power Apps    LinkedIn   
  • JK-08051902-0 Profile Picture
    on at
    Thanks for the inspiration @WarrenBelz! I ended up scraping the idea of using the "AT" symbol, and decided to go with comment tags outside of the comment dialog and I am pretty happy with it. I have not been able to find any versions of comments for canvas with replies, so I was happy to get this working.
     
    Note that for this case I have a gallery of Projects (not shown here) that the comments are part of. So each project has its own comments section. You could implement this with no projects table.
     
    I ended up taking a different route, but I am feeling pretty good about where things have landed.
    This is what my comments section looks like:
    Data Structure (Tables in Dataverse in my case, but I can imagine a Sharepoint version):
     
    Comments Table - Unique ID, Comment Text, Project ID/lookup (optional if the comments are associated with a particular record). For reference, I am using an auto increment ID in the Dataverse Name field (so when you see Project.Name in my code below, it is referring to this unique autonumber from the referenced table).
    Replies Table - Unique ID, Comment ID (or lookup to comments table), Reply Text
    Comment Tags Table - Unique ID, Lookup to Comments Table, User field (could be Microsoft Entra ID Table Lookup)
    Reply Tags Table - Unique ID, Lookup to Replies Table,  User field (could be Microsoft Entra ID Table Lookup)
     
    Screen Structure
     
    There is a main gallery for Comments, with a sub gallery added inside of the gallery rows (added to the first/template row) for replies. The Replies Table is mapped to the Comments Table by filtering on the Project ID.
    Items in the Replies Table:
    Filter('Comment Replies',Comment.Name=TextCanvas13.Text)
    The TextCanvas13.Text is a text label in the comments gallery.
     
    There is a comment input field with a send button, a tags dropdown and a tags label:
    The "Tag People" dropdown is populated in my case with the Microsoft Entra ID Dataverse Table (this is available by default in Dataverse). I can imagine this being populated by Office365Users as well. When the user selects a person to tag from the dropdown, I am grabbing the user from the dropdown and adding them one at a time (not multi select) to a collection. The following is added to the onchange of the dropdown. Note that I am checking if it is blank since it will add blank items when it is autocleared.
    If(!IsBlank(First(Self.SelectedItems)), Collect(colTaggedPeople,First(Self.SelectedItems)));
    Reset(ComboboxCanvas1);
    When the user hits the send button, I am patching the comment to the comments table (putting it inside of a Set() statement which returns the patched item to the varNewComment so that we can reference it when patching the tags. I had initially intended to loop through all of the colTaggedPeople to patch them to the Comment Tags table, but the platform blocked looping and patching one item at a time. So here, I am patching the first three (and if you want to allow more, just continue the Index(colTaggedPeople, 4)... 5,6, etc). I couldn't find a solution to dynamically loop and get as many as the user wants. You can see that I reset the text input, and clear the colTaggedPeople collection.
     
    Set(varNewComment,Patch('Project Comments',Defaults('Project Comments'),{Comment:TextInput1.Text,Project:Gallery1.Selected}));
    Patch('Comment Tags', Defaults('Comment Tags'),{'comment tagged person':First(colTaggedPeople),comment:varNewComment});
    'PowerAppV2->Compose'.Run(First(colTaggedPeople).Mail, Gallery1.Selected.Name);
    If(CountRows(colTaggedPeople) > 1,
        Patch('Comment Tags', Defaults('Comment Tags'),{'comment tagged person':Index(colTaggedPeople,2),comment:varNewComment});
        If(CountRows(colTaggedPeople)>2,Patch('Comment Tags', Defaults('Comment Tags'),{'comment tagged person':Index(colTaggedPeople,3),comment:varNewComment}));
        
    );
    
    Reset(TextInput1);
    Clear(colTaggedPeople);
    For replies, I am using a popup window:
     
     
    I have a second collection for varTaggedReplyPeople which get added to with the same method as above with the Comment tagging.
    Then the patch looks pretty much the same with the Replies, but adding the reference to the Comment.
     
    Set(varCurrentReplyItem,Patch('Comment Replies',Defaults('Comment Replies'),{'Reply Text': TextInputCanvas1.Value,Comment:varCurrentItem}));
    Patch('Reply Tags', Defaults('Reply Tags'),{'Reply Tagged Person':First(colTaggedReplyPeople),Reply:varCurrentReplyItem});
    If(CountRows(colTaggedReplyPeople) > 1, 
        Patch('Reply Tags', Defaults('Reply Tags'),{'Reply Tagged Person':Index(colTaggedReplyPeople,2),Reply:varCurrentReplyItem});
        If(CountRows(colTaggedReplyPeople)>2, Patch('Reply Tags', Defaults('Reply Tags'),{'Reply Tagged Person':Index(colTaggedReplyPeople,3),Reply:varCurrentReplyItem}));
    );
    
    Reset(TextInputCanvas1);
    Set(varShowReplyBox,false);
    I created the reply popup with a regular container with its visible property set to a variable which gets set to true when the reply button is pressed and set to false at the end of the patch statement (or when cancel is clicked).
     
    Just a note, set your comment fields to Autoheight=true. This will help with sizing the gallery rows. Also I have struggled to get the spacing to work well. In one version I set the main gallery's TemplateSize dynamically to the height of the comment text field plus the reply gallery's height plus a bit for the tags (in my case 150). I also created a version where all of the sizes were set statically which made for a more stable visual experience, but there were some downsides including more space between things than I wanted. So I suggest playing around with these and see what works best. Also note that when the app is in editing mode, the galleries can look pretty crazy and overlapping, but when it is played it straightens its self up. This aspect has taken the most tweaking.
     
     
     
     
  • WarrenBelz Profile Picture
    153,079 Most Valuable Professional on at
    Good to see you got it working - as I mentioned my suggestion was really only a rather messy workaround for something Power Apps did not cater for. Please confirm it did work for you as marking it as a solution for your actual question will assist others to find it in the future.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard