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

Problem with lookup fields

Hi,

 

I have a simple case. I have 2 custom entities: "Listings" and "Listing Interest" with 1:N relationship.

 

I have a gallery filled with "Listings" items with checkboxes and a collection is created for all the checked items. I want to create multiple new "Listing Interest" records. Each created "Listing Interest" record needs to have Lookup field "Listing"(new_listing) populated with the listing from which it was created (selected in gallery).

 

I tried to use patch and collect but in both cases, there's an error basically saying "new_listing" field doesn't exist (but it clearly does).

I went and created the collection from "Listing Interest" records to see what's in it, and for some reason, there are no columns with the names of lookup fields only some object type fields named something like "new_Listing_new_listing_interest". When I try to pass selected item to that column it says "The 'Listing' column in the data source you're updating expects a 'dataEntity' type and you're using a 'Record' type.

 

What am I missing? How can I pass selected item to lookup field?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Problem with lookup fields

Hi @IvanMislav ,

Could you please share a bit more about your Patch formula?

Could you please share more details about the error message within your app?

 

Based on the scenario that you mentioned, I think the "new_Listing_new_listing_interest" is actually the LookUp field in your "Listing Interest" Entity.

 

I have made a test on my side, and don't have the issue that you mentioned. Please consider take a try with the following workaround:4.JPG

 

5.JPG

Set the OnSelect property of the "Patch" button to following formula:

ForAll(
       RenameColumns(Filter(BrowseGallery1.AllItems, Checkbox1.Value=true),"crba2_tasklistsid", "crba2_tasklistsid1"),
       Patch(
           [@Tasks],
           Defaults([@Tasks]),
           {
               Subject: "PowerApps Portal - " & 'Primary Name',
               TaskLists: LookUp(TaskLists, TaskLists = crba2_tasklistsid1)
           }
       )
)

On your side, you may need to type the following formula:

ForAll(
       RenameColumns(Filter(BrowseGallery1.AllItems, Checkbox1.Value=true),"new_Listing", "new_Listing1"),  /* <-- new_listing should be the Unique Identifier column in your "Listings" Entity  */
       Patch(
           [@'Listing Interest'],
           Defaults([@'Listing Interest']),
           {
               'Primary Name': "xxx",
               Listing: LookUp(Listings, Listing = new_Listing1) /* <-- Listings represents your Listings Entity. Listing represents the Unique Identifier column (Display name) in your Listings Entity */
           }
       )
)

Note: The Listing represents the LookUp field (Display name) in your "Listing Interest" Entity.

 

Please take a try with above solution, then check if the issue is solved.

 

Best regards,

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.

View solution in original post

3 REPLIES 3
Highlighted
Community Support
Community Support

Re: Problem with lookup fields

Hi @IvanMislav ,

Could you please share a bit more about your Patch formula?

Could you please share more details about the error message within your app?

 

Based on the scenario that you mentioned, I think the "new_Listing_new_listing_interest" is actually the LookUp field in your "Listing Interest" Entity.

 

I have made a test on my side, and don't have the issue that you mentioned. Please consider take a try with the following workaround:4.JPG

 

5.JPG

Set the OnSelect property of the "Patch" button to following formula:

ForAll(
       RenameColumns(Filter(BrowseGallery1.AllItems, Checkbox1.Value=true),"crba2_tasklistsid", "crba2_tasklistsid1"),
       Patch(
           [@Tasks],
           Defaults([@Tasks]),
           {
               Subject: "PowerApps Portal - " & 'Primary Name',
               TaskLists: LookUp(TaskLists, TaskLists = crba2_tasklistsid1)
           }
       )
)

On your side, you may need to type the following formula:

ForAll(
       RenameColumns(Filter(BrowseGallery1.AllItems, Checkbox1.Value=true),"new_Listing", "new_Listing1"),  /* <-- new_listing should be the Unique Identifier column in your "Listings" Entity  */
       Patch(
           [@'Listing Interest'],
           Defaults([@'Listing Interest']),
           {
               'Primary Name': "xxx",
               Listing: LookUp(Listings, Listing = new_Listing1) /* <-- Listings represents your Listings Entity. Listing represents the Unique Identifier column (Display name) in your Listings Entity */
           }
       )
)

Note: The Listing represents the LookUp field (Display name) in your "Listing Interest" Entity.

 

Please take a try with above solution, then check if the issue is solved.

 

Best regards,

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.

View solution in original post

Highlighted
Frequent Visitor

Re: Problem with lookup fields

Hi @v-xida-msft ,

 

Thanks for the response. Yes, it seems that new_Listing_new_listing_interest is in fact Lookup filed so I was able to pass the value simply by passing the selected item to that field:

 

{new_Listing_new_listing_interest: Gallery1.Selected.Item}

 

But now I'm having difficulties with Regarding field which is a polymorphic lookup. Regarding field is named  _regardingobjectid_value so I tried to do the same:

 

{_regardingobjectid_value: [@ModelDrivenFormIntegration].Item} (Model-driven context is a Lead record)

 

I get the following error message:

The requested operation is invalid. Server Response: An error occurred while validating input parameters: Microsoft.OData.ODataException: A property '_regardingobjectid_value' which only has property annotations in the payload but no property value is declared to be of type 'Edm.Guid'. In OData, only navigation properties and named streams can be represented as properties without values.

 

Do you have any idea how to solve this?

Highlighted
Community Support
Community Support

Re: Problem with lookup fields

Hi @IvanMislav ,

Please check the following article or blog for more details:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/working-with-references#understand-rega...

 

https://powerapps.microsoft.com/en-us/blog/owner-customer-and-regarding-for-canvas-apps/

 

Best regards,

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
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Users online (4,164)