I have hit the limit of lookup fields SharePoint allows in my list (tblProjects) but need to relate one or more permits (from tblPermits) to each project. So I want to use a separate junction table (tblProjects_Permits) with two fields, a single-value lookup (Project) referencing tblProjects and a single-value lookup (Permit) referencing tblPermits. Basic schema like this:
I have a PowerApps form for data entry to tblProjects with a combobox that lets me select one or more permits. Like this:
When the form is submitted I want it to add a row to tblProjects_Permits with the project name in Project and the permit name in Permit for each permit selected in the combobox. So if I'm on the form for Project One and selected in the permits combobox Permits 001 and 229 it would add two rows to tblProjects_Permits like this:
I'd also need it to delete rows that are deselected if I happen to go back to the form to edit a project later.
I've been able to add a custom card to the form and add a multiselect combobox with Items coming from tblPermits. But I don't know how to get it to add or delete rows in tblProjects_Permits with the relevant project and permit. I'm thinking Patch but how to iterate through selected items in the combobox? And how to get the ID of the project if it is new?