cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
thomasgarcia83
Helper III
Helper III

Patch Functionality and Sending Text to a Comment Log

Hello all,

 

I found myself in another pickle on a separate project and I thought i was going down a good path but I've reached an intersection that I am having difficulty in crossing.

 

We all know the current limitations with append comments and SharePoint functionality. I hope that one day, this will be solved for all of us, easily. The current project that I am drafting out will require a collaboration log. See included screenshot for a visual of functionality I wish to achieve. 

 

I am using the Patch statement in the following context shown in the code viewer. However, I am overwriting data in the Collaboration_x0020_Log column every time I click on the Submit Comment button. If I manually go into the SharePoint list on the backend, I can insert a new comment and not overwrite the data. How would I effectively achieve this using PowerApps?

 

Patch('iTestList', Gallery1.Selected , {Collaboration_x0020_Log: NewCommentInput.Text})

Visual of Intended Comment Log FunctionalityVisual of Intended Comment Log Functionality

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Thanks,

-Tom

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Eureka!!! @Shanescows,

 

Thanks so much, buddy! I truly owe you a drink of your choice if we ever meet each other! 

 

This worked wonderfully. I cannot thank you enough for the teachings.

 

In case someone else could use the same solution, here is the final working code:

 

Patch(iTestList, Gallery1.Selected , 
{Collaboration_x0020_Log: Gallery1.Selected.Collaboration_x0020_Log & Char(13) &
NewCommentInput.Text})

 

CommentLogFunctionality-100Percent.JPG

 

 

View solution in original post

8 REPLIES 8
Shanescows
Super User
Super User

I have this working for a customer so no worries. 🙂 

 

Patch(SharePointList, YourItem, OldValue & NewValue) 

 

So I follow your code something like:

 

Patch('iTestList', Gallery1.Selected , {Collaboration_x0020_Log: Gallery1.Selected.Collaboration_X0020_Log & Char(12) & NewCommentInput.Text})

That is all from memory so may not be perfect but that is the jist.  

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training

Hi @Shanescows,

 

So good to talk with you again! I actually visited your boldzebras site this morning, haha!

 

Can you explain the "& Char (12)" portion of the code? I find that interesting and would like to know more about that, rather than just copy and paste it into my formula bar and move on. 🙂

 

I'm excited to try this. Thanks for the input Shane.

 

-Tom

No problem Tom glad I can help.

 

Actually, it should be Char(13) That inserts a New Line (before adding your text. Assuming you want them to all line up nice. 

 

More on the function here. You just feed it Ascii codes and get that behaviour. I use it a lot when creating Emails for example. 

Shane - Microsoft MVP, YouTube, and PowerApps Consulting for when you are in a bind to get this fixed quickly. And finally we now have PowerApps Training

Eureka!!! @Shanescows,

 

Thanks so much, buddy! I truly owe you a drink of your choice if we ever meet each other! 

 

This worked wonderfully. I cannot thank you enough for the teachings.

 

In case someone else could use the same solution, here is the final working code:

 

Patch(iTestList, Gallery1.Selected , 
{Collaboration_x0020_Log: Gallery1.Selected.Collaboration_x0020_Log & Char(13) &
NewCommentInput.Text})

 

CommentLogFunctionality-100Percent.JPG

 

 

View solution in original post

@thomasgarcia83 @Shanescows 

 

Hi guys,

 

Hope you dont mind me asking another question here but I'm new to all this and trying to wrap my head round it still!

 

I have used the below solution but every time I add a new comment it just appends to the end - how would I create a new line for each comment and further add user name and dates?

 

I'm using:

Patch(RequestUse_1,Gallery3.Selected,{CaseNotes:Gallery3.Selected.CaseNotes & Char(13) & TextInput3})

Thanks in advance,

 

JimmyWork
Power Participant
Power Participant

Sorry for asking this in an old post. But how do i display the latest comment first. So when i Patch i want the latest comment to come on top. 

2019-12-02 15_50_53-Test Design - Saved (Unpublished) - PowerApps.png

 

 

@MP4249 ,

 

Sorry this took me a while to see and respond. In order to append to the next line, or start a new line. You must insert an additional Char(13) at the very end of your statement. This sort of cheats and inserts a blank "row" to separate the previous comment for example:

 

Code Snippet w/ Line Break at End:

 

Patch(iProductIssues, 
  Gallery3.Selected,
  {Collaboration_x0020_Log: Gallery3.Selected.Collaboration_x0020_Log &
    Char(13) &
         User().FullName & Char(32) &
          Text("on") & Char(32) & 
          Text( Now(), "[$-en-US]mm/dd/yyyy at hh:mm:ss AM/PM" ) & Char(32) & 
          Text("commented:") & 
    Char(13) &
          NewCommentInput.Text & 
    Char(13)
  }
);

 

 

Not Using an Additional Char(13) Results from Code Snippet:☹️

 

Sample User Name on 12/03/2019 at 8:50 AM commented:

This comment does not use an additional Char(13) at the end of this comment. Sample User Name on 12/03/2019 at 8:51 AM commented:

This is the second comment after the first post.

 

Using an Additional Char(13) Results from Code Snippet:😀

 

Sample User Name on 12/03/2019 at 8:50 AM commented:

This comment does use an additional Char(13) at the end of this comment.

 

Sample User Name on 12/03/2019 at 8:51 AM commented:

This is the second comment after the first post.

 

Keep in mind, the Sample User Name is just fictitious in this post, I was just trying to illustrate the outcome. Let me know if I can be of some help. This has been a wonderful product that Mr. Shane helped me with awhile back and has made our app very useful.

 

- Tom 

@JimmyWork,

 

Unfortunately, I could never figure this out. I am not sure that this is even possible at all because the responding field in your list, database or similar is just seeing this all as text and such. I have yet to figure out a way to tell the responding field to do what you are asking. 

 

What I did was during my app training I tried to drill into my users that in order to view the comments, one would need to scroll to see the most recent. Out of all the enhancements request, this one has never come up so I guess most users either accept or don't question it. Your miles may vary though. 😉

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (86,618)