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

Error Using Patch to Create Record with Polymorphic field

I have a convas app draws data from the CDM. I have a custom entity with a customer lookup field. I am able to update records including the the customer lookup field with my current patch command. However when I attempt to use the same command to create a record with a value populated for the customer lookup field, I receive the following error but only if I include the polymorphic value. Without that value the create works without issue. The property being called in the patch command is _customvalue_value. I have tried adding a _customvalue_type but it says it is not a valid column because it does not exist.

Annotation 2019-09-26 132622.png

8 REPLIES 8
Highlighted
Resident Rockstar
Resident Rockstar

Re: Error Using Patch to Create Record with Polymorphic field

Hi @JohnBrown,

Can you post a screen shot showing how you populate your lookup field before patching your record please ?

Emmanuel

Highlighted
Frequent Visitor

Re: Error Using Patch to Create Record with Polymorphic field

@R3dKap  Sure, see below,

The Lookup has Items:

Annotation 2019-09-27 074351.png

And the Radio_DonorType is just two radio options of account and contact(UI has Individual and Organization but nehind the scenes it translates to the appropriate value). It has the following default setting to populate it. I am able to edit both types with the radio button and it updates the items on the lookup as expected. It is only the creates that seems to have a problem. 

Annotation 2019-09-27 074804.png

 

 

Highlighted
Resident Rockstar
Resident Rockstar

Re: Error Using Patch to Create Record with Polymorphic field

Hi @JohnBrown,

I don't know about polymorphic lookups in CDS but reading your initial post made me realize that you're facing the problem only in CREATION mode, not in UPDATE mode.

Would you mind posting a capture of your PATCH call in CREATION mode please ?

Thanks,

Emmanuel

Highlighted
Frequent Visitor

Re: Error Using Patch to Create Record with Polymorphic field

@R3dKapsure, the patch command is the same for edit and creation see below:

Annotation 2019-09-27 124733.png

 

 

Highlighted
Impactful Individual
Impactful Individual

Re: Error Using Patch to Create Record with Polymorphic field

Hi @JohnBrown 

At first glance at you posted formulas, I believe you are using deprecated old notation for lookups with *_value and *_type.
This isn't valid anymore with recent PowerApps releases (since a few months) which have the "Relational Data, option sets, and other new features for CDS" preview feature turned on by default.
image.png
The same applies to the deprecated *_label and *_value notation for multiselect option fields.

Have you seen this piece of documentation?
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/working-with-references
It shows how things are done with the new, more comfortable notation.
In particular, you'll want this:
image.png
Regular lookups work just the same.
You mentioned customer, so see also this, a bit further down the page. image.png

You can probably also use the typed versions (I'm in German language instance, Kontakte=Contacts, Besitzer=Owner, Benutzer=User, Team=Team, Unternehmenseinheit=Business Unit), that you can find with the auto-completion.
image.pngimage.png

Note that it's just this easy, if you put in a proper record straight from the source.
Putting in something from Global variables, Context variables, or local collections is more complicated.


Also, note that the new features do, for all intents and purposes, require you to be online.
The old _label, _value, _type stuff worked offline basically out of the box.
Offline functionality with the new features is more complicated.

Best of luck,
    Sa Wu.

Highlighted
Frequent Visitor

Re: Error Using Patch to Create Record with Polymorphic field

@SaWuThank you for the advice. I have looked at that article. To make it more closely align with it, I made the following changes

-Updated to use the regular name and not _customname_value

-Shifted to two comboboxes one for contacts and one for accounts and pass in the value based on the radio button value

but still receive the same error.

 

Annotation 2019-09-27 142201.png

Highlighted
Impactful Individual
Impactful Individual

Re: Error Using Patch to Create Record with Polymorphic field

Hi @JohnBrown 

Yeah, I get the same error for trying with a "Customer" field for a custom entity
image.png
It looks like they changed things again and the documentation isn't really working.
I just tried the embedded Owner example and get this:
image.png
For now it looks we're out of luck.

Maybe you can use one lookup field each to Contacts and Accounts (and optionally a business workflow to set the customer field from the Contact/Account field inside Dynamics) as a workaround?

Best of luck,
    Sa Wu.

Highlighted
New Member

Re: Error Using Patch to Create Record with Polymorphic field

Hi, im having the same issue trying to create new Case (Incident) with CustomerId polymorphic field.

Error Message:

"An error occurred while validating input parameters: Microsoft.OData.ODataException: A property '_customerid_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.


My Patch code on button select:

Patch(
    Cases,
    Defaults(Cases),
    {
        title: DataCardValue10.Text,
        _customerid_value: First(
            Filter(
                Contacts,
                'Contact (contactid)' = Dropdown5.Selected.'Contact (contactid)'
            )
        )
    }
)

Upon submitting, i see that the "Request Payload" JSON (in developer tools) is:

{"title":"test123","_customerid_value@odata.bind":"contacts(78d62f07-716d-e911-a95c-000d3a34e4b0)"}


However, when generate a jQuery API using the CRM RestBuilder, the syntax is:

var entity = {};
entity["customerid_contact@odata.bind"] = "/contacts(78d62f07-716d-e911-a95c-000d3a34e4b0)";
entity.title = "test123";

 
Is this a Microsoft Issue? Else, a little help would be much appreciated. Thanks!

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (11,415)