How to Utilize the PowerApps Remove Function for Field Deletion

How to Utilize the PowerApps Remove Function for Field Deletion

How to Remove Fields from a Record in PowerApps Using DropColumns

 

For anyone working with data in PowerApps, understanding the nuances of data manipulation is key.
One such essential operation is removing fields from a record. In this guide, we’ll walk you through
the steps to effectively remove fields from individual records using DropColumns and a simple workaround.

Why Remove Fields from a Record?

When dealing with data-driven applications, specific situations demand the removal of certain fields.
For instance, records might contain temporary working fields that are only required during the app’s operation.
Such fields could be temporary sequence numbers or ones meant to enhance the app’s presentation.

However, when it comes to saving these records to a data source, these additional fields may become unnecessary.
At this juncture, it’s optimal to remove them, especially before passing the record to functions like
Patch() in PowerApps.

Dropping Columns vs. Removing Fields

While PowerApps provides a handy DropColumns function to remove columns from tables,
the same isn’t directly available for individual records. But don’t worry—there’s a simple workaround!

Step-by-Step Guide to Remove Fields from a Record

Consider a record stored in a variable named varRecord:


Set(varRecord, {
  Forename: "Tim",
  Surname: "Leung",
  Address: "10 Kings Road",
  City: "London",
  UpdateDatabase: true,
  SequenceNo: 5
});
    

The above record contains two specific fields – UpdateDatabase and SequenceNo.
To exclude these fields and retrieve the modified record, use the following syntax:


First(
  DropColumns(
    Table(varRecord),
    "UpdateDatabase",
    "SequenceNo"
  )
)
    

Patching the Modified Record

To patch this cleaned-up record to a data source:


Patch(
  CustomerList,
  Defaults(CustomerList),
  First(
    DropColumns(
      Table(varRecord),
      "UpdateDatabase",
      "SequenceNo"
    )
  )
)
    

Conclusion

In PowerApps, while there isn’t a direct RemoveField or DeleteField function
for records, you can still remove fields by converting the record to a single-row table and using
DropColumns. Then use First() to extract the cleaned-up record.

It’s all about understanding the tools at hand and using them creatively to meet your app’s requirements.

Need help with PowerApps? Feel free to reach out to us for expert guidance (consulting services are chargeable).

 

Leave a Comment

Your email address will not be published. Required fields are marked *