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

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
Community Support Team
Community Support Team

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
Community Support Team
Community Support Team

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

IvanMislav
Level: Powered On

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?

Community Support Team
Community Support Team

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
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Users Online
Currently online: 400 members 4,482 guests
Recent signins:
Please welcome our newest community members: