When we work with data, there can sometimes be the requirement to rename field names in the record.
An example of where this can happen is in situations where we want to retrieve a record from one data source and to patch it into another data source. With this use case scenario, it may be necessary to rename the field names of the source record so that they match the field names in the target data source.
When we work with tables of data, we can call the RenameColumns function to rename the column of the table. When we work with a single record however, there's no equivalent function to rename the field name of an individual record.
To work around this limitation, one technique is to create a single row table that contains the record, rename the column, and to extract the record withe the renamed column.
Demonstration of how to rename a record field name
As an example, let's take the following formula that defines a record and stores it in a variable called varRecord. In practice, we could retrieve this record from a data source, Flow, or a custom connector.
Address:"10 Kings Road",
Here's how the record looks in the designer.
Let's now suppose that we want to rename Forename to Firstname, and Surname to Lastname. The formula to carry out this task would look like this:
Here's the formula to store this record in a variable called varRecordNew:
Finally, here's how this new record looks in the designer:
With Power Apps, there's no "RenameFields" to rename the fields of a single record. However we can work around this limitation by transforming the record into a table and calling the RenameColumns function.