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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Comparing two record v...
Power Apps
Suggested Answer

Comparing two record variables and highlighting changes

(1) ShareShare
ReportReport
Posted on by 20
Good afternoon everyone,
 
My app has the following behaviour:
 
1.  User selects a record from a gallery with an Items property directly referencing a SharePoint list.
2.  My app performs a lookup of the ID for the SharePoint list item against the selected gallery ID and saves the resulting record as a variable (gvSelectedRecord).
3.  The user is taken to a screen with controls which all have DefaultSelectedItems & Default values linked to gvSelectedRecord.  For example, I have a full name text box control with a Default value of gvSelectedRecord.'Full Name'.  There is a control for each of the columns in the SharePoint list.
4.  The user clicks a button to progress to a review screen.  Before navigating to the screen, I am taking all the current values of the controls and saving them as a different variable record (gvRequestDetails).
5.  The user is taken to a review screen which contains a review gallery.  The gallery Items property is:
With({_rec: gvRequestDetails},
Ungroup(
Table(
{Name: "Full name", Value: Text(_rec.fullName.field), Screen: _rec.fullName.screen, SPColumnName: "Title"},
{Name: "Location", Value: Text(_rec.location.field.Value), Screen: _rec.location.screen, SPColumnName: "Location"}...
etc.
I have labels in this gallery for the column name in a user friendly format, the value the user has provided, a screen number (for the purposes of a button navigating to a specific screen if the user wants to change a value they've provided) and a SPColumnName (which is the system/exact name of the column in SharePoint).
 
What I am trying to achieve is a way of comparing gvSelectedRecord and gvRequestDetails to see if the user has made any changes.
 
For example: If I were to change the Full name text box control of the selected record from John Smith (SharePoint list value - held in gvSelectedRecord.'Full Name') to David Smith (the value provided in the text box control and value stored in gvRequestDetails), I want the label in my review gallery which displays the value of 'David Smith' to have an indicator that the value has been changed (e.g. an asterisk at the start or the label should display in bold).
 
Is this possible? If so, how would I go about doing this?
 
Sorry if my explanation isnt great but I am happy to provide further detail if required!
Categories:
I have the same question (0)
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,969 Moderator on at
    Hi
     
    What if instead, you were to capture the record in a Collection of your own making
    For each piece of data instead of just having myfield: value you would have something like
     
    myfield: { 
         Orgvalue: fromitemselected,
         HasChanged: true or false,
         NewValue: Blank OR the value from the Onchange event of the Text Input or Selected dropdown etc
    }
     
    Now you can easily see what has changed and was has not
     
    A thought
  • XenDance Profile Picture
    20 on at
    Hi,
     
    Thanks for the response.
     
    I ended up resolving this problem after considerable thought.  This is my solution:
     
    With({_rec: gvRequestDetails, _originalrec: gvSelectedRecord},
    Ungroup(
    Table(
    {Name: "Full name", Value: Text(_rec.fullName.field), Screen: _rec.fullName.screen, OValue: _originalrec.Title},
    {Name: "Location", Value: Text(_rec.location.field.Value), Screen: _rec.location.screen, OValue: _originalrec.Location.Value}...
    etc.

    By changing the items property of the gallery to the above, I was able to adjust the following properties of the gallery label displaying the value from my form:
     
    FontWeight: If(ThisItem.Value = ThisItem.OValue, FontWeight.Normal, FontWeight.Bold)
    Color: If(ThisItem.Value = ThisItem.OValue, RGBA(0,0,0,1), RGBA(0,255,0,1))
    etc.
     
    I did think about setting up a collection to store values from my form but it would need a considerable rewrite of all the controls on my screens so I was trying to avoid this if possible.  In regards to what you have suggested, it could work, however - what would happen if the user changed a Text input control (thus triggering the OnChange event) and then decided against the change and then deleted their new text? My understanding is the value would still show as being changed?
     
    I'm aware my solution is probably not the optimal solution so if anyone has any better suggestions I would be happy to listen to your thoughts!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 530

#2
WarrenBelz Profile Picture

WarrenBelz 459 Most Valuable Professional

#3
Haque Profile Picture

Haque 314

Last 30 days Overall leaderboard