SAP Knowledge Base Article - Public

3019379 - Duplicate Values in the CustomerOrderItemCollection OData Service

Symptom

When you are executing a GET call for the CustomerOrderItemCollection entity, you are getting two entries with same Object ID

Environment

SAP Cloud for Customer

Reproducing the Issue

Execute the below GET call in the Chrome Browser or Odata Console

https://myXXXXXX.crm.ondemand.com/sap/c4c/odata/v1/c4codataapi/CustomerOrderItemCollection?$filter=SalesOrderID eq 'YYYYY'

XXXXXX - Tenant ID

YYYYY    -  Sales Order ID

You will get two entries with same Object ID.

Cause

Duplicate Entries for Sales Order is returned in OData because there are two Item Schedule Lines of type code = 1 (requested) exists for the item with different requested dates.This might be coming from ERP. So, the data need to be verified in ERP. Currently this is the supported behavior of Order OData service in case there are multiple entries for Requested Item Schedule lines (type 1) for an Order Item. If you check the result closely, you can see that the both the entries have different StartDateTime values.

Resolution

To resolve this, you need to write a logic in your custom solution where you are consuming the OData service to filter the 2 entries by comparing the StartDateTime for both entries incase the ObjectID is same and pick the one with latest date to get the desired single result.

Keywords

Odata, CustomerOrderItemCollection, Duplicate Entries , KBA , LOD-CRM-INT-API , OData API (C4C Only) , Problem

Product

SAP Cloud for Customer add-ins all versions