web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Issues with Patching a...
Power Apps
Answered

Issues with Patching and Polymorphic Lookup

(0) ShareShare
ReportReport
Posted on by 55

I'm using the CDS and custom tables: Customers and Sites.

Sites has a lookup column to Customers and I am having issues patching a record to Sites that references Customers.

 

Screenshot 1: The form. All fields are directly included in the Patch function on the Save button

Screenshot 2: The ComboBox for Customer has Items set to Customers.Name

 

The OnSelect of the Save button is set to (line generating error bolded):

Patch(
Sites,
Defaults(
Sites
),
{
Name: Concatenate(SiteStreetTextInput.Text, ", ", SiteCityTextInput.Text, ", ", SitePostalTextInput.Text),
'Street Address': SiteStreetTextInput.Text,
City: SiteCityTextInput.Text,
'Postal Code':SitePostalTextInput.Text,
Customer: SiteCustomerComboBox.Selected
}
);

 

Screenshot 3: Error text

 

I am vaguely familiar with polymorphic lookups (IsType/AsType) but unable to mentally wrap my head around what I need to do in this situation.


Greg

Untitled.jpg
Screen Shot 2021-02-11 at 4.47.27 PM.png
Screen Shot 2021-02-11 at 4.46.26 PM.png
Categories:
I have the same question (0)
  • Verified answer
    v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @deltaformtech ,

     

    At my knowledge, 'customer' column can refer to 'Accounts' or 'Contacts' entity. These two entities are system entities. You could not refer to a custom entity.

    v-xiaochen-msft_3-1613096970460.png

     

    If you want to use 'customer' column, I suggest you replace the referenced entity.

    I did the test for you.

    1\ Add a combo box control 'ComboBox1' and set its Items property to:

    Contacts

     

    2\ Add a button control and set its onselect property to:

    Patch(Sites,Defaults(Sites),{Name:"11",Customer:ComboBox1.Selected})

     

    3\ Click the button and the result is as follows:

    v-xiaochen-msft_0-1613096766753.png

    v-xiaochen-msft_1-1613096812838.png

     

    In addition , If you want to refer to custom entity, I suggest you use lookup column.

    v-xiaochen-msft_2-1613096917027.png

     

    Best Regards,
    Wearsky
    If my post helps, then please consider Accept it as the solution to help others. Thanks.

  • deltaformtech Profile Picture
    55 on at

    Hey Wearsky,

     

    I found the source of my issue.  I had the Items property of SiteCustomerComboBox set to "Customers.Name" instead of just "Customers". Once I updated that, I was able to Patch the Customers record to a Lookup column in Sites.

     

    Thank you!

     

    Greg

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 320 Most Valuable Professional

#2
11manish Profile Picture

11manish 210

#3
Valantis Profile Picture

Valantis 167

Last 30 days Overall leaderboard