When we work with data, there can sometimes be the requirement to delete or remove fields from a record.
An example of where this can happen is in situations where we define a record that may contain 'working fields' to support the operation of an app. This could include temporary sequence number, or fields to support the appearance or presentation in the app.
At the point at which we want to save the record to a data source, there may be the requirement to remove these extraneous fields so that we can pass the record to the Patch function.
When we work with tables of data, we can call the DropColumns function to drop columns from the table. When
we work with a single record however, there's no equivalent function to drop fields from an individual record.
To work around
this limitation, one technique is to create a single row table that contains the record without the unnecessary columns and to extract the first record from this table.
Demonstration - How to remove fields from a record
As an example, let's take the following formula that defines a record
and stores it in a variable called varRecord.
Address:"10 Kings Road",
The definition of this record contains two fields for use in our app - UpdateDatabase and SequenceNo.To return the record without these two fields, we would use the following syntax.
We can then use this syntax to patch the record (without these two fields) to a data source. The syntax would look like this:
With Power Apps, there's no "DeleteFields" function to delete or remove fields from a
single record. However, we can work around this limitation by transforming the record into a table, dropping the columns, and returning the first record from this table.