cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
whatupe
Level: Powered On

Patch a CDS Lookup column within PowerApps

I am trying to patch a lookup column from a form in my PowerApps app.  The form is submitted (successfully) and the data is saved to my primary table.  Once successfully saved, I use the OnSuccess event of the form to save items from a gallery into my second table, which is defined like this:

 

meeting guest room dates.PNG

 

The code for OnSuccess is:

 

ForAll(RoomsCollection, If(!IsBlank(LineItemDate),Patch('Meeting Guest Room Dates', Defaults('Meeting Guest Room Dates'), {cr623_primaryname:Text(LineItemDate), cr623_date:LineItemDate, cr623_singles:SingleRooms, cr623_MeetingServicesSiteResearch:Form2.LastSubmit})))

Here is the error I get:

meeting guest room dates2.PNG

As I understand it, the LastSubmit property of the form is the record that was saved, and the Lookup column requires a record, so I'm trying to figure out what I'm doing wrong here.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
whatupe
Level: Powered On

Re: Patch a CDS Lookup column within PowerApps

Finally figured this out - hopefully it can help someone else.  I'm not sure if this is the most effecient way, but it works

 

ForAll(RoomsCollection, If(!IsBlank(LineItemDate),Patch('Meeting Guest Room Dates', Defaults('Meeting Guest Room Dates'), {cr623_primaryname:Text(LineItemDate), cr623_date:LineItemDate, cr623_singles:SingleRooms, cr623_MeetingServicesSiteResearch:LookUp('Meeting Services Site Researches',cr623_meetingservicessiteresearchid=Form2.LastSubmit.cr623_meetingservicessiteresearchid)})))

The difference is, for cr623_MeetingServicesSiteResearch, I do a Lookup and use the id from the LastSubmit

View solution in original post

2 REPLIES 2
Highlighted
whatupe
Level: Powered On

Re: Patch a CDS Lookup column within PowerApps

Finally figured this out - hopefully it can help someone else.  I'm not sure if this is the most effecient way, but it works

 

ForAll(RoomsCollection, If(!IsBlank(LineItemDate),Patch('Meeting Guest Room Dates', Defaults('Meeting Guest Room Dates'), {cr623_primaryname:Text(LineItemDate), cr623_date:LineItemDate, cr623_singles:SingleRooms, cr623_MeetingServicesSiteResearch:LookUp('Meeting Services Site Researches',cr623_meetingservicessiteresearchid=Form2.LastSubmit.cr623_meetingservicessiteresearchid)})))

The difference is, for cr623_MeetingServicesSiteResearch, I do a Lookup and use the id from the LastSubmit

View solution in original post

arthurzhu
Level: Powered On

Re: Patch a CDS Lookup column within PowerApps

Hi,

 

I got a similar requirement to update the parent and child  entities on the same form - that is to patch (create) the parent entity first then use the value for the column (in your case LastSubmit) to create a new record in the child entity.

 

But in my case I am having issue referencing the column name of the child entity - I can see it in the format of Chilld_entity_column_name.Parent_entity_column_name and the Editor keeps saying column name invalid. Any ideas of fixing this?

 

Thank you,

 

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 (4,660)