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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to find primary key(s) for an F&O entity?

(2) ShareShare
ReportReport
Posted on by 62

Normally I can figure out the (sometimes composite) primary key for an F&O entity, but so far I have had no luck finding the key for any of these entities:

ItemSpecificBillOfMaterialsHeaders

ItemSpecificBillOfMaterialsHeadersV2

ItemSpecificBillOfMaterialsHeadersV3

A sample record looks like this:

{
"dataAreaId":"xyz",
"BOMId":"BOM_00000001",
"ManufacturedItemNumber":"SM-HC9578-002A",
"ProductionSiteId":"01",
"ProductColorId":"",
"ProductConfigurationId":"",
"ProductSizeId":"",
"ProductStyleId":"",
"BOMName":"HC9578-002A",
"IsActive":"Yes",
"ApproverPersonnelNumber":"000013",
"IsApproved":"Yes",
"EngChgEngineeringBomReference":"",
"EngChgEngineeringVersion":""
}

Odata URL for above record: 

/data/ItemSpecificBillOfMaterialsHeaders?$top=1

For simple GET queries I can always use $filter to get what I need; but in this case I need to do a PATCH update, and thus I need the exact primary key.

I queried the metadata thusly:

/data/$metadata

...and that brought a torrent of json data. Yes, I did find all 3 entities mentioned above, but the info it's giving me is certainly not the primary key(s). For example:

<NavigationProperty Name="ItemSpecificBillOfMaterialsHeaders" Type="Collection(Microsoft.Dynamics.DataEntities.ItemSpecificBillOfMaterialsHeader)" Partner="ProductionSite">
   <ReferentialConstraint Property="SiteId" ReferencedProperty="ProductionSiteId" />
   <ReferentialConstraint Property="dataAreaId" ReferencedProperty="dataAreaId" />
</NavigationProperty>

Those 2 properties SiteId and dataAreadId are the same in most records--not even close to unique.

So I have been using the trial-and-error method, such as:

  • /data/ItemSpecificBillOfMaterialsHeaders(dataAreaId='hoft',BOMId='HOFT-006037',ManufacturedItemNumber='344-25SW')
  • /data/ItemSpecificBillOfMaterialsHeaders(BOMId='HOFT-006037')
  • /data/ItemSpecificBillOfMaterialsHeaders(BOMId='HOFT-006037',ManufacturedItemNumber='344-25SW')

In all cases I get back this error:

<Error>
<Message>No HTTP resource was found that matches the request URI 'hfcorp-uat.sandbox.operations.dynamics.com/.../ItemSpecificBillOfMaterialsHeadersV3(dataAreaId='hoft',BOMId='HOFT-006037',ManufacturedItemNumber='344-25SW')'. No route data was found for this request.</Message>
</Error>

There must be a way in F&O to look up the primary key of an entity so that a PATCH request can be done against it. How is it done?

I have the same question (0)
  • Suggested answer
    Sukrut Parab Profile Picture
    71,735 Moderator on at

    Did you check entity in visual studio ? Key is defined at the entity level.

    entitiy-Key.jpg

  • HerrimanCoder Profile Picture
    62 on at

    What am I doing wrong with this URL, then:

    /data/ItemSpecificBillOfMaterialsHeadersV2(BOMId='HOFT-006037',ManufacturedItemNumber='344-25SW',ProductionSiteId='01',ProductColorId='',ProductConfigurationId='000448',ProductSizeId='',ProductStyleId='',ProductVersionId='')

    Error: No HTTP resource was found that matches the request URI...no route data was found for this request.

    This URL is the basis for my URL above:

    /data/ItemSpecificBillOfMaterialsHeadersV2?$filter=BOMId%20eq%20%27HOFT-006037%27

    And this is the JSON returned from that URL (with $filter in it):

    {

      "dataAreaId":"hoft",

      "BOMId":"HOFT-006037",

      "ManufacturedItemNumber":"344-25SW",

      "ProductionSiteId":"01",

      "ProductColorId":"",

      "ProductConfigurationId":"000448",

      "ProductSizeId":"",

      "ProductStyleId":"",

      "ProductVersionId":"",

      "BOMName":"344-25SW",

      "IsActive":"Yes",

      "ApproverPersonnelNumber":"000013",

      "IsApproved":"Yes"

    }

  • Verified answer
    Alex VN Profile Picture
    1,994 on at

    Hi,

    It seems like the entity you are used is a legal entity specific so you might need to include dataAreaID key into the key list as well:

    dataAreaId='usmf')

    Note the lower case "d" in "dataAreaId".

    Regards,

    Anh Ong

  • HerrimanCoder Profile Picture
    62 on at

    Thank you - when I added dataAreaId, it worked. In case anyone from MS is watching this, there really should be a simply way, in odata, to get back the PK fields for any given entity. Would save so much trouble.

  • PK-30061407-0 Profile Picture
    3 on at
    I have a similar problem like @HerrimanCoder. Did you get this to work?
  • Martin Dráb Profile Picture
    239,029 Most Valuable Professional on at
    Actually, OData already supports it. If you download OData metadata ([your F&O URL]/data/$metadata) and locate the entity, you'll find the key definition there:

    This is normally used by tools, such as code generators, but you can look there too.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 659

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 465 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 304 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans