cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
skylitedave
Level 10

How to add an item to a related lookup list and the list using the lookup at the same time

Hi 

 ... Here is a tough one for you to think about....  thought  I would share since I thought about this one long and hard,

 

Background - These are SharePoint Lists

  • I have an Account List in SharePoint
  • I have a Contact List in SharePoint
  • The Account list has a lookup column that lets the user add an exsiting contact from the Contacts List
  • I have a Form that lets the user add a new Contact from within the Account
  • I have a save button on the Account Form

 

When a user enters a new Account, they will likely also want to add a new Contact record at the same time So I let the user enter in the account info and also enter in the Contact Info - 2 forms - 1 to accounts and 1 to contacts

 

When The user hits save on account, I submit both forms ( the new account and the new Contact)

 

With me so far ??  🙂

 

Now here is trick

I submit the Account form first then I submit the Contact form and store the Account ID in that Contact List

I want to put in that new contact into the lookup field in the account after I save the Account and Contact

I put the following Patch in the On Success of the New Contact Form I created when I eneterd in the new account

 

MainContactA is the lookup to Contacts in the Account List

 

 

Patch(Accounts,  First(Filter(Accounts, ID = Account_New_Contact_Form.LastSubmit.AccountID)),
{MainContactA:
                       {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                        Id:Account_New_Contact_Form.LastSubmit.ID,
                        Value:Account_New_Contact_Form.LastSubmit.Title}
})

 

PowerApps is happy and this does save the New contact into the Contact list and  the lookup in Accounts

 

Hope that made sense ....  Very tricky stuff!

1 REPLY 1
Community Support Team
Community Support Team

Re: How to add an item to a related lookup list and the list using the lookup at the same time

Hi @skylitedave,

 

Could you please share a bit more about your scenario?

Do you mean that the Patch function addes a new record into your Accounts list rather than modify the existing item within the Accounts list?

Further, could you please share a bit more about your app's configuration?

 

If you could provided more details about your scenario, we would provided a proper workaround for you.

 

Best regards,

Kris

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (6,422)