Skip to content

Writing reference links on batch insert for nullable navigation keys #941

@ExpDev07

Description

@ExpDev07

When attempting to write reference links on deep insert as seen here, it throws on #ToDictionary(...) for navigation keys that per the schema have Nullable=false, but you can actually omit them and let the API generate them (we disable validations).

Take for example schema:

<EntityType Name="purchaseInvoice">
  <Key>
    <PropertyRef Name="documentType" />
    <PropertyRef Name="no" />
  </Key>
  <Property Name="documentType" Type="Edm.String" Nullable="false" />
  <Property Name="no" Type="Edm.String" Nullable="false" MaxLength="20" />
  <NavigationProperty Name="purchaseInvoiceLines" Type="Collection(Microsoft.NAV.purchaseInvoiceLine)" Partner="purchaseInvoice" ContainsTarget="true">
    <ReferentialConstraint Property="documentType" ReferencedProperty="documentType" />
    <ReferentialConstraint Property="no" ReferencedProperty="documentNo" />
  </NavigationProperty>
</EntityType>

documentType and no can be omitted and generated by the API (despite being non-nullable per schema), however, when deep inserting with purchaseInvoiceLines, it attempts to create links and fails as it can not get them.

Anyone have any workaround that does not include having to insert invoice lines one by one?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions