Skip to main content

Notifications

Announcements

No record found.

Supply Chain Management forum
Suggested answer

How to find the composite key of an entity for odata query purposes?

Posted on by 52

I'm trying to find the composite key of an extended F&O entity named ExpEcoResReleasedProductVariants. There are 3 pieces to the screenshot below:

  1. (top-left) The source/parent of the entity extension is EcoResReleasedProductVariant and you can see the keys.
  2. (bottom-left) You can see the keys for the custom entity ExpEcoResReleasedProductVariants.
  3. (right-center) You can see that ExpEcoResReleasedProductVariants really does exist and contains records. I can query these records via browser GET using filter syntax, but I must have key syntax in order to do PATCH operations against the entity.

HF.png

A PATCH operation against F&O odata is required to be structured like this:

/data/ExpEcoResReleasedProductVariants(ProductMasterNumber='243-1001',ProductConfigurationId='000377',ProductSizeId='',ProductColorId='',ProductStyleId='')

I have also tried the following permutations:

/data/ExpEcoResReleasedProductVariants(ProductMasterNumber='243-1001',ProductConfigurationId='000377',ProductSizeId='',ProductColorId='',ProductStyleId='',ItemNumber='243-1001')

/data/ExpEcoResReleasedProductVariants(ProductMasterNumber='243-1001',ProductConfigurationId='000377',ProductSizeId='',ProductColorId='',ProductStyleId='',ItemNumber='243-1001',ProductMasterNumber='243-1001')

I have tried various combinations and permutations of what you see above, but in all cases I get errors like this:

<Error>

<Message>No HTTP resource was found that matches the request URI 'https://***.sandbox.operations.dynamics.com/data/ExpEcoResReleasedProductVariants(ProductMasterNumber='243-1001',ProductConfigurationId='000377',ProductStyleId='',ProductSizeId='',ProductColorId='',ItemNumber='243-1001')'. No route data was found for this request.</Message>
</Error>
How can I find the correct composite key so I can structure the odata request correctly so I can perform a PATCH against it? Note: The URL structure above will perform a valid GET and show data like in the screenshot, when it is correct. As mentioned, the screenshot above displays good data from an odata GET only by using filter syntax, not by using "composite key" syntax. For example:
/data/ExpEcoResReleasedProductVariants?$filter=ProductMasterNumber eq '243-1001' and ProductConfigurationId eq '000377'
What the AOT shows for keys is apparently not correct, else it would work.
I have downloaded /data/$metadata and that gives me a ton of data, but the keys for ExpEcoResReleasedProductVariants are not listed. In most cases, entity keys are listed in that metadata dump, but this one isn't.
There must be some solid way to know how to construct an F&O odata query using composite key patch syntax with the correct key attributes. How can it be found?
Thanks in advance for any help.

  • Martin Dráb Profile Picture
    Martin Dráb 225,783 Super User on at
    How to find the composite key of an entity for odata query purposes?
    I've just noticed that the screenshot shows the entity key of a wrong entity. HerrimanCoder claimed that we can see the keys for the custom entity ExpEcoResReleasedProductVariants, but it's not true. The screenshot shows EcoResReleasedProductVariantEntity; it doesn't tells us anything about the custom entity.
  • Suggested answer
    grkonda Profile Picture
    grkonda 2 on at
    How to find the composite key of an entity for odata query purposes?
    Not sure if this is resolved already but I did face the same issue and solution is:
    ExpEcoResReleasedProductVariants(ProductMasterNumber='PRD-10001',ProductConfigurationId='',ProductSizeId='',ProductColorId='',ProductStyleId='A1',ProductVersionId='')
     
    Though ProductVersionId is not part of the composite primary key, it still expected as part of the PATCH url. This worked fine for me
     
  • HerrimanCoder Profile Picture
    HerrimanCoder 52 on at
    RE: How to find the composite key of an entity for odata query purposes?

    I had tried that as well. It doesn't work.

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 225,783 Super User on at
    RE: How to find the composite key of an entity for odata query purposes?

    It's not clear to me why you tried all the other options if you know that the entity key is ItemNumber + ProductMasterNumber. What you're missing in your last attempt is the identification of the legal entity: the DataAreaId field (as the first field in the request).

  • HerrimanCoder Profile Picture
    HerrimanCoder 52 on at
    RE: How to find the composite key of an entity for odata query purposes?

    I forgot to mention that I had also tried:

    /data/ExpEcoResReleasedProductVariants(ItemNumber='243-1001',ProductMasterNumber='243-1001')

    ...but that doesn't work either. No surprise, not enough attributes to guarantee uniqueness in the record.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,459 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,783 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans