cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Not able to store data in 'Lookup' fields. Not able to establish relationship between two entities.

Hi,

 

I have created an app using CDS. For this, I have created a couple of custom entities. And established relations by creating lookup fields.

 

I am not able to store data into these lookup fields through powerapps. My formula is below:-

Patch('Captured Photos',Defaults('Captured Photos'),{Photo:{Value: Newimage.Image, Full: Newimage.Image}},{'Customer ID':GUID})

 

Heare Customer ID is my lookup field and GUID is variable which contains a unique value. After doing lots of RND. there lots of questions in my mind like can we use patch function to add the record into a lookup field and way I have created app is wrong.

 

Is there any proper way to deal with the relational entities or lookup fields. 

 

Could you please help me out of it. 

 

2 REPLIES 2
Highlighted
Super User II
Super User II

Hi, 

 

So for a lookup field, you need to pass an actual record, not just the GUID. Which is what the error is saying as well. 

 

Try this, 

 

Patch('Captured Photos',Defaults('Captured Photos'),{Photo:{Value: Newimage.Image, Full: Newimage.Image}},{'Customer ID': LookUp(Customers, CustomerID = GUID)})

 

Assuming that the lookup entity name is Customer l, the unique ID field on that entity is called CustomerID. Also, if your GUID is a text variable, you might want to use the GUID function. 

 

So something like this:

 

Patch('Captured Photos',Defaults('Captured Photos'),{Photo:{Value: Newimage.Image, Full: Newimage.Image}},{'Customer ID': LookUp(Customers, CustomerID = GUID(GUID))})

 

Let me know if this helps. 

 

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution.

 

Thanks!
Hardit Bhatia

Microsoft Business Applications MVP 
https://thepoweraddict.com

Highlighted

Hi Hardit,

 

Many thanks for your reply. 

 

I have tried with that and its work properly, value is coming into the Lookup field.

But the question is how can we confirm the relation between two entities.

 

The relationship between the two entities is the same as the primary and foreign key relationships in SQL.

 

 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Users online (9,727)