How to Bulk Edit in PowerApps

Giving your users the ability to edit multiple records at one time is a big time saver especially in an admin app as in the demo below. In this tutorial I will show you step by step how to bulk edit in PowerApps. Continue reading and you too will be an office power user!

How-to-bulk-edit-in-PowerApps

First thing we will need is some data to update. I am using data stored in a SQL table but if you need some data to work with in this tutorial then you can create the collection below and place it in an onVisible of a blank screen. Let’s create it now!

Setting up Your Data

  • Screen:
    • OnVisible:
      ClearCollect(
      tblWPO_Items,
      {
      WPO: “Cell-Phone/ Radio”,
      WPODesc: “No cellphone used while working and/or walking.”,
      ID: 1
      },
      {
      WPO: “Access”,
      WPODesc: “Use safe routes to accessing work areas.”,
      ID: 3
      }, {
      WPO: “Height”,
      WPODesc: “Best safety practices and utilizing only approved devices.
      ,
      ID: 3
      }
      )

Setting up the Gallery

After inserting your blank vertical gallery be sure to have the gallery selected and insert the following controls within the gallery.

  • Gallery: Insert a blank vertical gallery.
    • Name: GalleryWPOs
    • X: 418
    • Y: 282
    • Width: 911
    • Height: 475
    • Items: tblWPO_Items // Gallery created above.
    • TemplateSize: 65
  • Text Input:
    • Name: TextInputWPO
    • X: 7
    • Y: 8
    • Width: 199
    • Height: 48
    • Default: ThisItem.WPO
  • Text Input:
    • Name: TextInputWPOdesc
    • X: 220
    • Y: 6
    • Width: 315
    • Height: 54
    • Mode: TextMode.MultiLine
    • Default: ThisItem.WPOdescription
  • Label: //Place anywhere in gallery.
    • Name: lblWPOEditedID
    • Visible: false
    • Text: ThisItem.ID
  • Check box: //Place anywhere in gallery.
    • Name: chckChanges
    • Visible: false
    • Reset: varResetcheckbox
    • Default: // This is key to making this all work!
      If(
      TextInputWPO.Text <> ThisItem.WPO || TextInputWPOdesc.Text <> ThisItem.WPOdescription,
      true,
      false
      )
  • Label:
    • Name: lblMessage
    • X: 577
    • Y: 40
    • Width: 175
    • Height: 25
    • Color: RGBA(255, 0, 0, 1)
    • Text: If(chckChanges.Value=true ,”Changes needing saving.”,””)
  • Icon:
    • Icon: Icon.Cancel
    • X: 738
    • Y: 42
    • Width: 20
    • Height: 20
    • Color: RGBA(255, 0, 0, 1)
    • Visible: chckChanges.Value=true
    • OnSelect: Reset(TextInputWPO);Reset(TextInputWPOdesc)

The Finishing Touches!

We are almost there, now we just need set up the update based on the items in the gallery that have been changed. Be sure to deselect the gallery as the last three controls inserted will not be done inside the gallery.

  • Label:
    • Name: lblWPOrecordsToSave
    • X: 1199
    • Y: 14
    • Width: 63
    • Height: 33
    • Color: RGBA(255, 0, 0, 1)
    • BorderThickness: 0
    • Visible: IconSaveEditsWPOs.Visible
    • Text: CountRows(Filter(GalleryWPOs.AllItems,chckChanges.Value=true))
  • Icon:
    • Icon: Icon.Save
    • Name: IconSave
    • X: 1198
    • Y: 15
    • Width: 64
    • Height: 64
    • Color: RGBA(102,121,126,1)
    • Visible: IconCancelEditsWPOs.Visible
    • OnSelect:
      UpdateContext({varShowSpinner: true}); // See link below on how to create a spinner component.
      ForAll(
      Filter(
      GalleryWPOs.AllItems,
      chckChanges.Value = true
      ),
      UpdateIf(
      ‘[dbo].[tblWPO_Items]’,
      // Changed to your data source name.
      ID = Value(lblWPOEditedID.Text),
      {
      WPO: TextInputWPO.Text,
      WPOdescription: TextInputWPOdesc.Text
      }
      )
      );
      UpdateContext({varResetcheckbox: false});
      UpdateContext({varResetcheckbox: true});
      Refresh(‘[dbo].[tblWPO_Items]’);
      // Changed to your data source name.
      UpdateContext({varShowSpinner: false})
  • Icon:
    • Icon: Icon.Cancel
    • Name: IconCancelEditsWPOs
    • X: 1277
    • Y: 14
    • Width: 64
    • Height: 64
    • Color: RGBA(102,121,126,1)
    • Visible: Value(lblWPOrecordsToSave.Text) > 0
    • OnSelect:
      UpdateContext({varResetcheckbox: false});
      UpdateContext({varResetcheckbox: true});

      Reset(TextInputWPO);
      Reset(TextInputWPOdesc)

Now you know how to bulk edit in PowerApps! Please leave your feedback. I hope this article has been helpful for you so bookmark this blog as new articles are be posted regularly. 

Additional Resources

how-to-create-a-spinner-component-in-powerapps
how-to-create-a-popup-confirmation-in-powerapps

Share the knowledge!

Paul Rodrigues

Business Analyst with 20 years of IT experience creating practical solutions. I love to automate business processes through the use of technology while making the end users work easier. My current favorite tools are PowerApps, Power BI and Power Automate. #PowerAddict

You may also like...

1 Response

  1. Joppel says:

    Thank you for the clear explanation. I can use this for many projects!

Leave a Reply

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