If you want to create a record with its child records in Power Pages, there is no way to do it using out of the box forms. But you can do it using JavaScript Power Pages Web API, and with a single Web API call.
In this blog post we will use the example of creating an Account with 2 child Contacts in Power Pages.
Prerequisites
- Enable both the Account and Contact tables for the WebAPI
- Enable the fields used in the WebAPI call for both tables (including the relationship field)
- Configure proper table permissions for both tables (so users can create items and associate contacts with accounts)
- Include the ‘WebAPI’ wrapper (sample from Microsoft) in a web template so you can use the webApi.safeAjax function as below
How to setup the request
In your JavaScript code, define a variable or constant with the object you want to submit.
This needs to contain all the fields from the parent object (account) and the array of child objects (contacts) under a property with the…
Source link
More About This Author
-
SharePoint and Office 365 Consultant/Developer always trying to get the best from Microsoft stack (Microsoft 365/Azure/Power Platform and related stuff).
Living in Ireland since 2018, I had previously worked in Brazil as a consultant/developer for Office 365, SharePoint and related technologies for almost 10 years.
Array
- Modern Workplace7 December 2024How to fix Web API requests with FetchXml being blocked by Power Pages Web Application Firewal
- Modern Workplace1 December 2024Get a Power Pages site URL dynamically per environment to send emails via Power Automate
- Modern Workplace29 November 2024Using Power Pages Web Application firewall to Rate limit Web API calls
- Modern Workplace23 November 2024Power Pages CSP: Starter Settings