<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Rick Hurt</title>
    <description>The latest articles on Forem by Rick Hurt (@rick_hurt).</description>
    <link>https://forem.com/rick_hurt</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1203319%2Fe6a8d5a1-31f5-40b8-8ba6-72c09e9c0d26.jpg</url>
      <title>Forem: Rick Hurt</title>
      <link>https://forem.com/rick_hurt</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/rick_hurt"/>
    <language>en</language>
    <item>
      <title>Enhancing Comment History Functionality in Power Apps</title>
      <dc:creator>Rick Hurt</dc:creator>
      <pubDate>Mon, 06 Nov 2023 18:03:20 +0000</pubDate>
      <link>https://forem.com/rick_hurt/enhancing-comment-history-functionality-in-power-apps-5fb7</link>
      <guid>https://forem.com/rick_hurt/enhancing-comment-history-functionality-in-power-apps-5fb7</guid>
      <description>&lt;p&gt;When working with SharePoint Online lists, it's easy to create a multi-line text field to capture comments and comment history for line items. SharePoint leverages version control to store and display these comments on your edit or display fields. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Febegj92zzzess0s3ktbo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Febegj92zzzess0s3ktbo.png" alt="Append Comment History in SharePoint"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, when it comes to working with version history in Power Apps, things can get tricky. In this post, we will explore an alternative way to simulate this functionality using a multi-line text field. This approach can be applied not just in SharePoint but also in Dataverse, SQL, or other data sources.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up the Multi-Line Text Field
&lt;/h2&gt;

&lt;p&gt;Start by creating a SharePoint list column with the data type set to "Multi-line" and configure it as plain text. Ensure that you do not select the "Append changes to existing text" option in the column settings.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmmaqj8kwgutk4kp0k65b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmmaqj8kwgutk4kp0k65b.png" alt="Create multiline text field"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a Power App
&lt;/h2&gt;

&lt;p&gt;For this demonstration, I've created a basic Power App with CRUD (Create, Read, Update, Delete) operations, and these operations are set up using the SharePoint integration feature.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9tzfjfgb3i1of8i49snc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9tzfjfgb3i1of8i49snc.png" alt="Basic Power App"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding Comment History Functionality
&lt;/h2&gt;

&lt;p&gt;In the Edit Screen, I made the following modifications:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;I added a Custom Card to include a new comment section.
Added a text box for entering comments.&lt;/li&gt;
&lt;li&gt;Inserted a ➕ button for adding comments to the comment history.&lt;/li&gt;
&lt;li&gt;Adjusted the size of the Comment History text box to accommodate multiple comment histories and changed its mode to "multiline."&lt;/li&gt;
&lt;li&gt;Set the display mode of the comment history to "Disabled" so that users can't directly edit it.&lt;/li&gt;
&lt;li&gt;For the ➕ icon's OnSelect action, you can add the following code. This code can also be added to your Form save button if you prefer not to have a separate button for adding comments:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;If(
    !IsBlank(txtAddComment.Text),
    UpdateContext(
        {
            varLocalCommentHistory: $"{User().FullName} ({Text(
                Now(),
                DateTimeFormat.ShortDateTime
            )}): {txtAddComment.Text}{Char(13)} {txtCommentHistory.Text}" // Char(13) gives you a line break between comments
        }
    )
);
Reset(txtAddComment)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;6.On your comments card, in the &lt;strong&gt;Default&lt;/strong&gt; property, you can add the following code:&lt;br&gt;
&lt;code&gt;If(!IsBlank(varLocalCommentHistory), varLocalCommentHistory, ThisItem.'Comments History')&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;7.In the ResetForm property of your form, you can add the following code:&lt;br&gt;
&lt;code&gt;UpdateContext({varLocalCommentHistory:Blank()})&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb0dvzenm2jc2pt2q6b8h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb0dvzenm2jc2pt2q6b8h.png" alt="Form updates"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The finished app provides a seamless way to capture and display comment history for line items. This approach is versatile and can be applied to various data sources, making it a valuable addition to your Power Apps toolkit.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxsis4wa10u1kos3zu8eh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxsis4wa10u1kos3zu8eh.png" alt="Finished app"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>powerplatform</category>
      <category>powerapps</category>
      <category>sharepoint</category>
      <category>powerfx</category>
    </item>
  </channel>
</rss>
