Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Add one or more rows to junction table based on combobox selected items

Posted on by

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:

 

_nerdy_0-1643527874487.png

 

I have a PowerApps form for data entry to tblProjects with a combobox that lets me select one or more permits. Like this:

_nerdy_1-1643528001814.png

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:

_nerdy_2-1643528240484.png

 

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? 

 

Categories:
  • Re: Add one or more rows to junction table based on combobox selected items

    Thanks @v-xiaochen-msft and apologies for such a delayed response 👍 This pointed me in the right direction.

  • Verified answer
    Re: Add one or more rows to junction table based on combobox selected items

    Hi @_nerdy ,

     

    "but how to iterate through selected items in the combobox"

     

    You could use ForAll() function.

    ForAll(Combox.SelectedItems,...)

     

    "And how to get the ID of the project if it is new? "

     

    You could set a variable to save the return value from patch function.

    Set(var,Patch(...).ID)

     

    Best Regards,

    Wearsky

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,591

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,090

Leaderboard