mambo chaminuka
mambo chaminuka

Reputation: 51

Write validation failed for table row of type 'PurchPurchaseOrderLineEntity'

I'm trying to post the the purchase order line details from postman using odata and I'm getting the following error.

{
"error": {
    "code": "",
    "message": "An error has occurred.",
    "innererror": {
        "message": "Write validation failed for table row of type 'PurchPurchaseOrderLineEntity'. Infolog: .",
        "type": "Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataValidateWriteException",
        "stacktrace": "   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.UpdateProcessor.CreateEntity_Save(ChangeOperationContext context, ChangeInfo changeInfo)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.UpdateManager.<>c__DisplayClass10_0.<CreateEntity>b__1(ChangeOperationContext context)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.ChangeInfo.ExecuteActionsInCompanyContext(IEnumerable`1 actionList, ChangeOperationContext operationContext)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.ChangeInfo.TrySave(ChangeOperationContext operationContext)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.UpdateManager.SaveChanges()\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataDelegatingHandler.<SaveChangesAsync>d__3.MoveNext()"
    }
}

}

I have tried checking these links but I'm not getting a breakthrough:

Below is my payload

{      
            "dataAreaId": "XXXX",
            "LineNumber": 1,
            "PurchaseOrderNumber": "XXXX-PO-000009",
            "ReceivingSiteId": "1",
            "LineDescription": "XXXXXXX XXXX XXXX",
            "ItemNumber": "SKU0000012530",
            "DIOTOperationType": "Blank",
            "LineAmount": 9687.19,
            "PurchasePriceQuantity": 1,
            "PurchasePrice": 9687.19,
            "PurchaseUnitSymbol": "EA",
            "OrderedPurchaseQuantity": 1,
            "DeliveryAddressName": "XXXXX XXXXX XXXX",
            "ProcurementProductCategoryName": "XXXXXX XXXXX XXXX",
            "ReceivingWarehouseId": "TG",
            "VendorInvoiceMatchingPolicy": "ThreeWayMatch",
            "RequestedDeliveryDate": "2021-09-03T12:00:00Z"
}

Anyone who can help me on this?

NB: The Purchase order header is working without any problem.

Upvotes: 0

Views: 3905

Answers (1)

FH-Inway
FH-Inway

Reputation: 5117

Despite the missing information in the question, I tried to reproduce the issue. My test setup was a 10.0.20 environment with contoso demo data. I used the DEMF company and created a new purchase order since the existing ones were either already invoiced and/or intercompany.

I created the new purchase order for vendor DE-001 and was able to create lines in it using an OData request sent by Postman.

While testing, I noticed that the response Postman receives does contain the infolog messages which are missing in the question. Either they were removed (in which case please [edit] the question and add them) or the version of D365 does not include them (in which case please [edit] the question to add the version information).

I also noticed that the payload in the question contains fields ItemNumber and ProcurementProductCategoryName. As far as I know, a purchase line can have only one of those two, but not both. If you manually create a line with either one, the other one will be locked for editing. So please retry your request without either the ItemNumber or the ProcurementProductCategoryName field.

For the record, here are the payloads that worked in my test setup:

Payload with procurement category

{      
            "dataAreaId": "DEMF",
            "LineNumber": 1,
            "PurchaseOrderNumber": "000011",
            "ReceivingSiteId": "1",
            "LineDescription": "XXXXXXX XXXX XXXX",
            "ProcurementProductCategoryName": "PAYROLL",
            "DIOTOperationType": "Blank",
            "LineAmount": 47.11,
            "PurchasePriceQuantity": 1,
            "PurchasePrice": 47.11,
            "PurchaseUnitSymbol": "EA",
            "OrderedPurchaseQuantity": 1,
            "DeliveryAddressName": "XXXXX XXXXX XXXX",
            "ReceivingWarehouseId": "11",
            "VendorInvoiceMatchingPolicy": "ThreeWayMatch",
            "RequestedDeliveryDate": "2021-09-03T12:00:00Z"
}

Payload with item number

{      
            "dataAreaId": "DEMF",
            "LineNumber": 1,
            "PurchaseOrderNumber": "000009",
            "ReceivingSiteId": "1",
            "LineDescription": "XXXXXXX XXXX XXXX",
            "ItemNumber": "D0001",
            "DIOTOperationType": "Blank",
            "LineAmount": 47.11,
            "PurchasePriceQuantity": 1,
            "PurchasePrice": 47.11,
            "PurchaseUnitSymbol": "EA",
            "OrderedPurchaseQuantity": 1,
            "DeliveryAddressName": "XXXXX XXXXX XXXX",
            "ReceivingWarehouseId": "11",
            "VendorInvoiceMatchingPolicy": "ThreeWayMatch",
            "RequestedDeliveryDate": "2021-09-03T12:00:00Z"
}

Upvotes: 5

Related Questions