Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / Error while querying s...
Finance forum

Error while querying salesorderline using OData

(0) ShareShare
ReportReport
Posted on by 417

Hi,

I am facing the below error while querying salesorderline using OData. 

Error:

The EDM instance of type '[Microsoft.Dynamics.DataEntities.SalesOrderHeader Nullable=True]' is missing the property 'SalesOrderLine'.

Code:

var salesOrdersWithLines = d365Client.SalesOrderHeaders.Expand("SalesOrderLine").Where(x => x.SalesOrderNumber.Equals("SO022288")).Take(5);

foreach (var salesOrder in salesOrdersWithLines)
{
Console.WriteLine(string.Format("Sales order ID is {0}", salesOrder.SalesOrderNumber));

foreach (var salesLine in salesOrder.SalesOrderLine)
{
Console.WriteLine(string.Format("Sales order line with description {0} contains item id {1}", salesLine.LineDescription, salesLine.ItemNumber));
}
}

Below is the screen shot showing sales order line for SO022288 in D365FO

so-line-error.png

Pls help.

Categories:
  • shaneooo Profile Picture
    5 on at
    RE: Error while querying salesorderline using OData

    This question is a couple months old now but I ran into a similar issue recently.  D365 v10.0 pu24.

    I had the same error using OData APIs for PurchaseOrderHeader joining to PurchaseOrderLines via `Expand`.  But if I used PurchaseOrderHeadersV2 joined to PurchaseOrderLinesV2, then it worked!  Perhaps SalesOrderHeadersV2/SalesOrderLinesV2 would work for you as well.  Or perhaps a later Platform Update or hotfix fixes this?

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,095 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,866 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans