
How to create a Power Apps form for SharePoint New, Edit and View mode
Discover the easiest method to use the Power Apps platform to make a custom form for all three modes of SharePoint forms – New, Edit and View.
To display related SharePoint list items in Power Apps, connect two lists through a Lookup column and use the Data Grid or Gallery control. Adding, editing, and deleting related items requires additional controls and Power Fx formulas.
But getting this to work isn't always straightforward.
I now want to add a "related projects" option where users can pull up a project and identify any other projects in the same list as related. I tried adding a lookup column that pulls in all the projects in the list, but couldn't get that to play nicely in Power Apps.
In this tutorial, I'll show you how to build a purchase request form with related products in Power Apps and compare this approach with Plumsail Forms' built-in List or Library control for internal and external forms.
In this article:
Employees use the form to enter request details and add as many products as necessary, all from one form.
Create two SharePoint lists to store this data.
Purchase Requests is our parent list. It contains general information about each request:
Requested by
Manager
Department
Purchase Items is the child list. It stores the products associated with each request:
Title (the product name)
Quantity
Unit Price
Purchase Request (a lookup column linking a product to its parent request)
The Purchase Request lookup column points to the Purchase Requests list. It links each product to its parent request by ID.
This establishes a one-to-many relationship: one purchase request can contain multiple purchase items, while each purchase item belongs to one request.
Power Apps gives you two main ways to work with SharePoint list data: customize the existing SharePoint form or create a standalone canvas app.
With Customize forms, Power Apps replaces the default SharePoint New, Edit, and Display forms. Users continue working directly in the SharePoint list, but with a customized interface. The form already knows which list item is being created or edited.
With Create an app, Power Apps generates a separate canvas application connected to your SharePoint list. You get more flexibility to design multiple screens, navigation, and additional functionality. However, you also need to manage how users navigate between records and how the application is shared.
For this tutorial, I will customize the SharePoint form. Employees will add and edit purchase items directly from the Purchase Requests list, without accessing a separate application.
Open the Purchase Requests list in SharePoint.
Select Integrate → Power Apps → Customize forms.
An auto-generated form connected to the Purchase Requests list opens.
Open the Data panel, expand Connectors, select SharePoint and add the Purchase Items list as another data source.
The form can now access both lists.
Now we need a way to display items related to the purchase request, with the ability to add new ones, edit or delete existing items.
The most common approach is to use a Gallery. However, we will try out the new modern Data Grid control. The control was recently released and replaces the deprecated Table control. With Data Grid control, users can select rows, sort data, and search records. Adding and editing products requires separate input controls and Power Fx formulas, which the following steps explain.
Add a modern Data Grid below the purchase request details and name it dgPurchaseItems.
In the control settings, open the Display tab and set SelectMultiple to false so users can select one product at a time:
The control will be connected to a collection called colPurchaseRows, which will temporarily store products while users work with the form. But first, we need to initialize the collection so Power Apps can recognize its columns.
Select the Data Grid. On the Advanced tab, set its Items property to:
Filter(colPurchaseRows, !Deleted)
Add a temporary button to the form and set its OnSelect property to:
ClearCollect(
colPurchaseRows,
{
RowKey: "sample-1",
ChildID: 0,
Product: "Laptop",
Quantity: 5,
UnitPrice: 850,
Changed: false,
Deleted: false
}
)
Hold Alt and click the button to execute the formula. This creates a collection containing a sample product and the fields we'll use later.
With the sample data loaded, select the Data Grid, then go to Display → Fields to configure the columns:
Add three columns: Product, Quantity, and UnitPrice.
The modern Data Grid supports different column types, including Text, Number, Email, and URL.
For our example, configure the columns as follows:
ThisItem.Product.ThisItem.Quantity.ThisItem.UnitPrice.You can also change the column headers and widths to make the table easier to read.
The Data Grid is now ready.
Below the Data Grid, add a container named conProductEditor. It will hold the controls for adding and editing products and be visible only when needed.
Set the editor container's Advanced → Visible property to:
!IsBlank(varEditorMode) &&
SharePointForm1.Mode <> FormMode.View
The editor appears only when a user chooses to add or edit a product.
Add three classic Text input controls for Product, Quantity, and Unit Price. For the Quantity and Unit Price fields, set the Format property to Number. These inputs will let users enter product details.
Set each input control's Advanced → Default property to the corresponding formula below:
//txtEditProduct
If(
varEditorMode = "Edit",
LookUp(colPurchaseRows, RowKey = varEditKey, Product),
""
)
// txtEditQty
If(
varEditorMode = "Edit",
Text(LookUp(colPurchaseRows, RowKey = varEditKey, Quantity)),
"1"
)
//txtEditPrice
If(
varEditorMode = "Edit",
Text(LookUp(colPurchaseRows, RowKey = varEditKey, UnitPrice)),
"0"
)
Add Save product and Cancel editing buttons inside the container.
The form now includes a Data Grid and a product editor:
For the Save product button, set its OnSelect property to:
If(
IsBlank(Trim(txtEditProduct.Text)) ||
!IsNumeric(txtEditQty.Text) ||
Value(txtEditQty.Text) <= 0 ||
!IsNumeric(txtEditPrice.Text) ||
Value(txtEditPrice.Text) < 0,
Notify(
"Enter a product name, valid quantity, and price.",
NotificationType.Error
),
If(
varEditorMode = "Add",
Collect(
colPurchaseRows,
{
RowKey: Text(GUID()),
ChildID: 0,
Product: Trim(txtEditProduct.Text),
Quantity: Value(txtEditQty.Text),
UnitPrice: Value(txtEditPrice.Text),
Changed: true,
Deleted: false
}
),
Patch(
colPurchaseRows,
LookUp(
colPurchaseRows,
RowKey = varEditKey
),
{
Product: Trim(txtEditProduct.Text),
Quantity: Value(txtEditQty.Text),
UnitPrice: Value(txtEditPrice.Text),
Changed: true
}
)
);
Set(varEditorMode, Blank());
Set(varEditKey, Blank());
Reset(dgPurchaseItems)
)
The formula validates the input, then uses Collect() to add a product or Patch() to update an existing row in the collection.
For the product editor's Cancel button, use this formula in its OnSelect property:
Set(varEditorMode, Blank());
Set(varEditKey, Blank())
Add buttons for Add, Edit, and Delete above the Data Grid.
For the Add button, set its OnSelect property to:
Set(varEditorMode, "Add");
Set(varEditKey, Blank());
Reset(txtEditProduct);
Reset(txtEditQty);
Reset(txtEditPrice)
For the Edit button, set its OnSelect property to:
If(
IsBlank(dgPurchaseItems.Selected.RowKey),
Notify(
"Select a product first.",
NotificationType.Warning
),
Set(varEditKey, dgPurchaseItems.Selected.RowKey);
Set(varEditorMode, "Edit");
Reset(txtEditProduct);
Reset(txtEditQty);
Reset(txtEditPrice)
)
To edit a product, select its row in the Data Grid, click Edit, update the details, and click Save product.
For the Delete product button, use this formula in its OnSelect property:
If(
IsBlank(dgPurchaseItems.Selected.RowKey),
Notify(
"Select a product first.",
NotificationType.Warning
),
With(
{
row: dgPurchaseItems.Selected
},
If(
row.ChildID = 0,
RemoveIf(
colPurchaseRows,
RowKey = row.RowKey
),
Patch(
colPurchaseRows,
LookUp(
colPurchaseRows,
RowKey = row.RowKey
),
{
Deleted: true,
Changed: true
}
)
)
);
Set(varEditorMode, Blank());
Set(varEditKey, Blank());
Reset(dgPurchaseItems)
)
Deleting a newly added product removes it from the collection. Deleting a product already saved in SharePoint marks it for deletion when the parent form is saved.
The Data Grid hides rows marked with Deleted = true, so the product disappears from the table immediately.
A new purchase request receives its SharePoint ID only after it is saved. Related products must therefore remain in a temporary collection until the parent request is saved.
Users can add, edit, and delete products in this collection before submitting the form.
Select the SharePointIntegration control and set its OnNew property to:
ClearCollect(
colPurchaseRows,
{
RowKey: "",
ChildID: 0,
Product: "",
Quantity: 0,
UnitPrice: 0,
Changed: false,
Deleted: false
}
);
Clear(colPurchaseRows);
Set(varEditorMode, Blank());
Set(varEditKey, Blank());
NewForm(SharePointForm1)
This initializes an empty collection with the fields our Data Grid expects and opens the parent form in New mode.
Employees also need to view existing purchase requests and edit their related products.
Reuse the same Data Grid and product editor. Load the products linked to the selected request from SharePoint into colPurchaseRows.
Edit form
Select the SharePointIntegration control and set its OnEdit property to:
EditForm(SharePointForm1);
Refresh('Purchase Items');
ClearCollect(
colPurchaseRows,
{
RowKey: "",
ChildID: 0,
Product: "",
Quantity: 0,
UnitPrice: 0,
Changed: false,
Deleted: false
}
);
Clear(colPurchaseRows);
Collect(
colPurchaseRows,
ForAll(
Filter(
'Purchase Items',
'Purchase Request'.Id =
SharePointIntegration.SelectedListItemID
) As item,
{
RowKey: Text(GUID()),
ChildID: item.ID,
Product: item.Title,
Quantity: item.Quantity,
UnitPrice: item.'Unit Price',
Changed: false,
Deleted: false
}
)
);
Set(varEditorMode, Blank());
Set(varEditKey, Blank())
This formula loads the products linked to the selected purchase request into colPurchaseRows.
The Data Grid displays these products because its Items property uses this collection.
Users can add products, edit existing ones, or mark them for deletion. These changes remain in the collection until the parent form is saved.
The OnSuccess formula in the next section creates, updates, and deletes related items in both New and Edit modes.
Display form
Copy the OnEdit formula to the OnView property of SharePointIntegration. In the opening statement, replace EditForm with ViewForm:
ViewForm(SharePointForm1)
This opens the parent form in View mode and loads its related products into the Data Grid.
To hide the Add, Edit, and Delete buttons in View mode, use the following condition in each button's Visible property. For Edit and Delete, combine it with the existing row-selection condition if you configured one:
SharePointForm1.Mode <> FormMode.View
Set the OnCancel property of SharePointIntegration to:
ResetForm(SharePointForm1);
Clear(colPurchaseRows);
Set(varEditorMode, Blank());
Set(varEditKey, Blank())
This resets the parent form, clears the product collection, and resets the editor variables when the user cancels the form.
When users click Save in the SharePoint form, save the parent request first. Then apply the changes to its related products, using the saved request's ID to link new items.
Set the OnSave property of SharePointIntegration to the formula below. It prompts users to save or cancel the product they are editing before submitting the parent form:
If(
!IsBlank(varEditorMode),
Notify(
"Save or cancel the product you're editing first.",
NotificationType.Warning
),
SubmitForm(SharePointForm1)
)
Next, select SharePointForm1 and set its OnSuccess property to the formula below. It applies the related product changes after the parent request is saved and collects any errors in colSaveErrors:
Clear(colSaveErrors);
With(
{
parent: SharePointForm1.LastSubmit
},
ForAll(
Filter(
colPurchaseRows,
Deleted && ChildID > 0
) As row,
IfError(
Remove(
'Purchase Items',
LookUp(
'Purchase Items',
ID = row.ChildID
)
),
Collect(
colSaveErrors,
{
RowKey: row.RowKey,
Message: FirstError.Message
}
);
Blank()
)
);
ForAll(
Filter(
colPurchaseRows,
!Deleted &&
(Changed || ChildID = 0)
) As row,
IfError(
Patch(
'Purchase Items',
If(
row.ChildID = 0,
Defaults('Purchase Items'),
LookUp(
'Purchase Items',
ID = row.ChildID
)
),
{
Title: row.Product,
Quantity: row.Quantity,
'Unit Price': row.UnitPrice,
'Purchase Request': {
Id: parent.ID,
Value: parent.Title
}
}
),
Collect(
colSaveErrors,
{
RowKey: row.RowKey,
Message: FirstError.Message
}
);
Blank()
)
)
);
If(
IsEmpty(colSaveErrors),
Clear(colPurchaseRows);
ResetForm(SharePointForm1);
RequestHide(),
Notify(
"The request was saved, but some product changes failed. Check the Purchase Items list before retrying.",
NotificationType.Error
)
)
The save process works as follows:
SubmitForm() saves the parent purchase request.ID to link new products to the request.ForAll() deletes existing SharePoint items marked for deletion.ForAll() uses Patch() to create new items and update modified ones, setting their Purchase Request lookup values.IfError() collects any errors from product changes in colSaveErrors.For example, saving a new request with three products creates one item in Purchase Requests and three related items in Purchase Items.
Save your changes and select Publish to SharePoint.
Now the same customized SharePoint form can create new purchase requests with multiple products, display existing related records, and add, edit, or delete products.
The important difference from saving records individually is that all changes are staged until users submit the parent form.
The Data Grid is only one option. Depending on the interface you want, there are several other approaches worth considering.
The classic Gallery control is more flexible than Data Grid when you need direct editing.
You can place Text input controls inside each gallery row, allowing employees to change product names, quantities, and prices in a line-by-line manner.
You can also add buttons for inserting and removing rows, making the gallery behave like a spreadsheet.
The downside is that you need to arrange the controls manually, configure how each input updates your collection, and handle saving changes to SharePoint.
Microsoft has an official tutorial showing how to create this type of interface: Create an app to edit tables in canvas apps.
For users who want to edit several products quickly, an editable Gallery may be more convenient than Data Grid with a separate editor.
The newer Card Gallery control displays records as responsive cards rather than table rows. It's also currently in preview.
It supports record selection, grouping, and multiple selections.
For our purchase request scenario, each card could show a product's name, quantity, and unit price. Users could select a card and edit its information through a separate Form or custom editor, much like the Data Grid approach.
For a practical example, see Reza Dorrani's video: Power Apps Just Got 4 NEW Modern Controls — Card Gallery, Metrics Card & More.
Power Apps can handle related SharePoint records, and it offers several ways to build the interface. You can use Data Grid for a modern table, an editable Gallery for inline changes, or separate forms for individual records.
However, the functionality for managing related SharePoint items still requires additional configuration.
For simple parent-child relationships, Power Apps is a workable option. And the newer controls make it easier to create modern-looking interfaces.
However, adding, editing, deleting, and saving multiple records together requires more configuration.
If your main goal is simply to manage related SharePoint items from a single form, there's a simpler approach.
Have you tried creating related SharePoint items with Power Apps? Which approach did you use, and what challenges did you run into?
Share your experience in our Reddit discussion and see how others have approached similar scenarios.
Plumsail Forms for SharePoint has a List or Library control specifically designed for working with related SharePoint lists and document libraries. It allows users to view, add, edit, and delete records from another list directly inside the parent form.
The control supports:
Unlike the Power Apps approach, you don't need to create a collection or write custom formulas to track new, modified, and deleted records.
Let's use the same Purchase Requests and Purchase Items lists.
We've already created the Lookup column in Purchase Items, so the relationship between the lists is ready.
Here's how to configure it:
Open the Plumsail Forms designer for the Purchase Requests list.
Add the List or Library control to the parent form, below the general request fields.
Select the data source. In the control settings, choose Purchase Items as the source list.
Configure the Lookup field. Select the Purchase Request column that links child items to their parent.
Choose a SharePoint view. You can create a view in the Purchase Items list containing Product, Quantity, and Unit Price, and use it in the control.
Select an editing mode. With Inline editing, employees can modify products directly in the table. With Dialog editing, each product opens in a separate form.
Save and test the form.
That's the main setup.
When an employee opens an existing purchase request, the control automatically displays the products linked to that request.
When creating a new request, the employee can add multiple products to the List or Library control. Plumsail handles saving the parent first and linking the new child items using the Lookup column.
For a basic setup, you don't need code to create or update records or link child items to the parent request. The control handles all of that automatically.
If you prefer dialog editing, you can also customize the child list's New, Edit, and Display forms to control which fields users see when adding or modifying a product.
For detailed instructions, see How to create a SharePoint form with associated items or documents and bind new ones automatically or watch the video tutorial:
The List or Library control handles most of the routine work involved in creating and managing related SharePoint records.
Advantages:
Limitations:
For a straightforward purchase request form, the List or Library control is easier to configure. But Power Apps provides more freedom if you need a fully custom application with interactions that go beyond working with related SharePoint records.
We keep track of material transfers between construction sites in one place, monitor consumption, and can process invoicing faster thanks to the information entered in [Plumsail Forms].
Read how Profibaustoffe CZ manages construction logistics in SharePoint Online →
Plumsail public forms has the List or Library control for a public form that has a direct SharePoint connection.
This opens up similar scenarios for users who don't have access to your SharePoint site.
For example:
You can configure the form to save the main submission to one SharePoint list and use List or Library to collect related records in another list.
For new submissions, users can add related items. When editing an existing submission, they can also view and modify the items already linked to it.
One useful detail is that changes made through the List or Library control are applied only when the public form is submitted. New child records are linked automatically to the parent item after submission.
Both solutions let users work with records from multiple SharePoint lists without manually switching between them.
The main difference is how much functionality you need to configure yourself.
| Feature | Power Apps forms | Plumsail Forms |
|---|---|---|
| Create related SharePoint items | Power Fx and custom controls | Built-in control |
| Automatically assign parent ID | Custom save logic | Automatic |
| Display existing child items | Data Grid, Gallery, or Card Gallery | Built-in control |
| Inline editing | With an editable Gallery | Built-in |
| Add and edit through a dialog or panel | Custom editor or Form control | Built-in |
| Delete related items | Custom logic | Built-in |
| Save child changes with parent | Custom collection and save logic | Handled by the control |
| Related document libraries | Requires custom implementation | Supported |
| Collect items from external users | Not through a standard customized SharePoint form | Supported with Plumsail public forms |
| Customization | Extensive with Power Fx | Interface designer |
| Licensing | Microsoft 365 or Power Apps, depending on features | Plumsail Forms subscription |
Choose Power Apps if you want full control over the interface or need complex interactions between multiple data sources. You'll also need the expertise to build and maintain Power Fx logic.
Choose Plumsail Forms if your main requirement is to create, display, and manage related SharePoint items without developing the underlying parent-child logic yourself. Plumsail public web forms also lets you collect related records from external users without giving them access to your SharePoint site.
Creating related SharePoint list items with Power Apps is possible using Lookup columns, Data Grid, galleries, and Power Fx. Power Apps gives you flexibility in how records are displayed and edited. However, you need to configure how parent and child items are saved and linked, including error handling. This requires development time and knowledge of Power Fx.
Plumsail Forms offers a simpler approach with its List or Library control. You can configure the relationship between SharePoint lists, add the control to the parent form, and let users manage related items without writing custom save logic. If you need similar functionality for external users, Plumsail public forms can also collect related records without requiring access to your SharePoint site.
Start a free trial of Plumsail Forms and see how the List or Library control can work for your scenario involving related SharePoint items.