Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Supply chain | Supply Chain Management, Commerce
Suggested answer

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

(0) ShareShare
ReportReport
Posted on by 56

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 231,305 Most Valuable Professional 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 56 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 231,305 Most Valuable Professional 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 56 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.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans