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 Workplace1 May 2024Using the new ‘Send a Microsoft Graph HTTP request’ action in Power Automate to send urgent messages in Microsoft Teams
- Modern Workplace13 April 2024Power Pages and Cloud Flows – Validate user against Dataverse records based on Contact ID
- Modern Workplace6 April 2024Download SharePoint library files in Power Pages with JavaScript and Cloud flows – Improved code using jQuery & option to open PDF file in a new tab
- Modern Workplace13 March 2024Handle multiple N:N records associate and disassociate requests with JavaScript and Power Pages Web API