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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Weird behavior when cr...
Power Apps
Unanswered

Weird behavior when creating a new "Case" record (CDS) from a canvas app

(0) ShareShare
ReportReport
Posted on by 7,316 Most Valuable Professional

A few months ago, when creating a new Case (CDS entity) record from a canvas app, we had to use the following approach to populate the Customer field (polymorphic lookup - Account or Contact): 
Approach #1

 

_customerid_value = XYZ
_customerid_type = "account"

 

Then at some point of time polymorphic lookups were made easier and all we had to do for populating the Customer field in a Case record was as shown below: 
Approach #2

 

Customer: First(Accounts)

 

 

Today, when I tried both approaches I got the following error: 

1. Approach #1: _customerid_type does not exist

2. Approach #2: CustomerID is required and missing. However, the editor/studio shows no error until you hit the button which is used to called Patch

 

Frustrated with errors in both approaches, I decided to go forward with Approach #2 since the editor/studio was not showing any error until I hit Patch. When I repeated the same functionality (hitting the button that called Patch) after playing the app, there was no error and the case record got created! Which is good in a way but very weird. 

 

Let me know if you need any more details. 

 

Thanks!

Hardit Bhatia

Blog | Twitter | LinkedIn | Facebook | YouTube  |  Email

 

Categories:
I have the same question (0)
  • v-yutliu-msft Profile Picture
    on at

    Hi @PowerAddict ,

    Do you want to know how to patch a lookup field?

    Usually we use a combo box to patch a lookup field, and set like this:
    1)the combo box's Items:

    Choices(entityname.fieldname)

    On your side is:

    Choices(entityname.Customer )//please replace with your entity name that has the lookup field

    2)use this formula to represent the value to patch Customer field:

    ComboBox1.Selected

    Then patch function could be like:

    Patch(entityname,Defaultse(entityname),{Customer:ComboBox1.Selected,....})

     

     

    Best regards,

  • timl Profile Picture
    36,411 Super User 2025 Season 2 on at

    Hi @v-yutliu-msft 

    Thanks for replying to this.
    What Hardit refers to here is a Polymorphic lookup - that is, a lookup that could store either an account or a contact.

    Using his formula in Approch #2 (which is standard syntax for this type of thing), it takes '2 goes' for the Patch to succeed.

    Unfortunately, I don't the answer to this, but is this something that you can recreate, as it would be useful for us to understand this behaviour?

  • PowerAddict Profile Picture
    7,316 Most Valuable Professional on at
    Thank you @timl! @v-yutliu-msft, here is the explanation again (please let me know if I am missing something or if you need more info).

    It's exactly that - trying to Patch a CDS case record and populating the Customer field (polymirphic lookup to Account or Contact). When we started off, the process was somewhat bad/inconvenient as we had to specify both _customerid_value and _customerid_type. Then it became much better as all we had to do was reference an account or a contact record using a syntac as simple as Customer: First(Accounts) as an example.

    Then suddenly Customer: First(Accounts) started throwing an error in the studio after I was hitting Patch, just to test my code. The error was something along the lines of "you need to specify a parent account or contact record".

    I tried specifying the values using the old method and it kept saying _customerid_type doesn't exist.

    After trying a few times, I decided to publish and play the app because there were errors in the editor with the new approach. When I published and played the app, a new case record got created perfectly.

    So while I was able to do what I set out to, I wanted to double check or flag it since the editor shouldn't be throwing an error for something thats correct in reality and also works fine when the app is published.

    Thanks,
    Hardit Bhatia

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard