Write validation failed for table row of type 'PurchPurchaseOrderLineEntity' - axapta

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:
https://powerusers.microsoft.com/t5/Connecting-To-Data/Error-creating-order-line-in-Dynamics-365-for-Operations/td-p/11927
https://community.dynamics.com/365/financeandoperations/f/dynamics-365-for-finance-and-operations-forum/378486/error-while-submitting-po-from-external-system-odata-d365-f-o
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.

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"
}

Related

How to create a segmented push using OneSignal

Here's the thing, I have two types of users, The Workers and Clients.. The workers can be at "n" categories as they want and what I'm trying to do is, when the client send a PUSH to a specific Category, every worker that was registered there must receive the notification.
I was trying to use the Tag approach by doing this :
"app_id": "APP_ID",
"tags": {
"first_name": "Jon",
"last_name": "Smith",
"level": "99",
"amount_spent": "6000",
"account_type": "VIP",
"key_to_delete": "\"\""
}
But, instead of having different properties, it must be the same Key (Category) so the service could recognize the category itself, something like : Reference
"app_id": "APP_ID",
"tags": {
"Category": "IT",
"Category": "Painter",
}
And if I try to create a tag with the same name, it just updates the value.

Azure CosmosDB - Partial Document Update (Patch) on Complex Structures

I'm trying to use the Partial Document Update (Patch API) to update a child object in my document, but I'm running into trouble. I found this Stack Overflow question which is the same question that I have. However, the accepted answer resolves the problem by referring to an object in an array by index. I don't believe that I have the luxury of being able to do that. So, to use the same example document as the other question...
{
"id": "SalesOrder2",
"ponumber": "PO15428132599",
"OrderDate": "2005-07-01T00:00:00",
"DueDate": "2005-07-13T00:00:00",
"ShippedDate": "2005-07-08T00:00:00",
"AccountNumber": "Account2",
"SubTotal": 6107.082,
"TaxAmt": 586.1203,
"Freight": 183.1626,
"TotalDue": 4893.3929,
"DiscountAmt": 1982.872,
"Items": [
{
"Id": 1,
"OrderQty": 3,
"ProductCode": "A-123",
"ProductName": "Product 1",
"CurrencySymbol": "$",
"CurrencyCode": "USD",
"UnitPrice": 17.1,
"LineTotal": 5.7
},
{
"Id": 2,
"OrderQty": 2,
"ProductCode": "A-456",
"ProductName": "Product 2",
"CurrencySymbol": "$",
"CurrencyCode": "USD",
"UnitPrice": 10,
"LineTotal": 20
}
],
"_rid": "BsMkAMc43s4CAAAAAAAAAA==",
"_self": "dbs/BsMkAA==/colls/BsMkAMc43s4=/docs/BsMkAMc43s4CAAAAAAAAAA==/",
"_etag": "\"00000000-0000-0000-e136-0dbec04601d7\"",
"_attachments": "attachments/",
"_ts": 1637760030
}
I have no guarantee that the item in the Items array with an Id of 1 would be in position 0 of the array. Similarly, the item with an Id of 2 is not guaranteed to be in position 1. Therefore I believe that I need to use the FilterPredicate parameter of the Patch API to filter my results. But when I attempt to do that, I keep getting the following exception:
Microsoft.Azure.Cosmos.CosmosException : Response status code does not
indicate success: PreconditionFailed (412); Substatus: 1110;
ActivityId: dbd258ae-0a0a-4a9b-8c25-1d36e137b7c5; Reason: ();
Any assistance you could provide on how to accomplish this would be appreciated.
As i answered in the attached link, Patch requires the user to pass the specific index of the object needs to be updated. We are working on enabling this particular feature in the coming months, However as an alternative, you should look at Conditional Patch
Code will be something like this,
response = patch(operation, Condition(check if item exists))
if(response == fail/precondition failed)
{
PatchOperation operation = PatchOperation.Add("/Items", [{"Id" : "P-1", "Description" : "My Product"}]);
}

Find and delete Discord webhook message

I'm using a Discord webhook to send information which may later be invalidated, so I want to be able to delete it. To do this i use these endpoints:
First i make a post request to send a message:
POST /webhooks/{webhook.id}/{webhook.token}
And then i want to do a delete request to remove the message again:
DELETE /webhooks/{webhook.id}/{webhook.token}/messages/{message.id}
However I don't have the ID of the message i want to delete, since no response is given to the first POST request which is always an empty 204 response. Is it possible to get the message id?
Any help would be appreciated.
Per this reddit post:
If you need to reference a message ID of a webhook message you sent, you can add ?wait=true to the end of the URL which will give you the message data (including the ID) instead of a 204 (No Content) when you don't include the query parameter.
So if you send your normal POST request to your url like this: POST /webhooks/{webhook.id}/{webhook.token}, add ?wait=true to the end of that. Then you will get back data like this:
{
"id": "MESSAGEID",
"type": 0,
"content": "This is a test",
"channel_id": "CHANNELID",
"author": {
"bot": true,
"id": "AUTHORID",
"username": "USERNAME",
"avatar": "AVATARID",
"discriminator": "0000"
},
"attachments": [],
"embeds": [],
"mentions": [],
"mention_roles": [],
"pinned": false,
"mention_everyone": false,
"tts": false,
"timestamp": "2021-11-13T18:10:24.412000+00:00",
"edited_timestamp": null,
"flags": 0,
"components": [],
"webhook_id": "WEBHOOKID"
}

Logic App to CosmosDB - PartitionKey extracted from document doesn't match the one specified in the header

I am using a CosmosDB connector in my logic app to insert a record into the database. My container name is ordersContainer. Here is my document:
{
"id": "98327158-59d3-4b5b-8c36-0b7c6270c18e",
"item": {
"headers": {
"salesNumber": "LXG995",
"dateTime": "12/23/2020 6:24:40 PM",
"locationId": "DDD444",
"locationName": "Wide World Importers",
"locationAddress": "645 Roosevelt Avenue",
"locationPostcode": "98121",
"totalCost": "424.55",
"totalTax": "42.455"
},
"details": [
{
"productId": "0f5a0fe8-4506-4332-969e-699a693334a8",
"quantity": "20",
"unitCost": "15.99",
"totalCost": "319.8",
"totalTax": "31.98",
"productName": "Beer",
"productDescription": "Hey this isn't ice cream!"
},
{
"productId": "76065ecd-8a14-426d-a4cd-abbde2acbb10",
"quantity": "10",
"unitCost": "4.49",
"totalCost": "44.9",
"totalTax": "4.49",
"productName": "Gone Bananas",
"productDescription": "I'm not sure how appealing banana ice cream really is."
},
{
"productId": "551a9be9-7f1c-447d-83ee-b18f5a6fb018",
"quantity": "15",
"unitCost": "3.99",
"totalCost": "59.85",
"totalTax": "5.985",
"productName": "Matcha Green Tea",
"productDescription": "Green tea ice cream is good for you because it is green."
}
]
}
}
In my container, my partition key is /salesNumber and in my connector, I have the 'salesNumber' (with double-quotes around it. However, I get this error:
"code": "BadRequest",
"message": "Message: {\"Errors\":[\"PartitionKey extracted from document doesn't match the one specified in the header\"]}\r\nActivityId: ba051769-46cc-4890-b199-c65841f3c0da, Request URI: /apps/a13f0c17-4c1e-488f-a4f7-e0fb0c98bb56/services/4b64d4a5-e7e4-4141-a4a1-5a53ab79bc4b/partitions/1108ee0f-f7e4-4572-b6f8-7c63bea5c122/replicas/132551652008533238p/, RequestStats: \r\nRequestStartTime: 2021-01-17T14:21:22.5778297Z, RequestEndTime: 2021-01-17T14:21:22.5778297Z, Number of regions attempted:1\r\nResponseTime: 2021-01-17T14:21:22.5778297Z, StoreResult: StorePhysicalAddress: rntbd://cdb-ms-prod-eastus1-fd59.documents.azure.com:14308/apps/a13f0c17-4c1e-488f-a4f7-e0fb0c98bb56/services/4b64d4a5-e7e4-4141-a4a1-5a53ab79bc4b/partitions/1108ee0f-f7e4-4572-b6f8-7c63bea5c122/replicas/132551652008533238p/, LSN: 5, GlobalCommittedLsn: 5, PartitionKeyRangeId: 0, IsValid: True, StatusCode: 400, SubStatusCode: 1001, RequestCharge: 1.24, ItemLSN: -1, SessionToken: 5, UsingLocalLSN: False, TransportException: null, ResourceType: Document, OperationType: Upsert\r\n, SDK: Microsoft.Azure.Documents.Common/2.11.0"
I'm not sure why it is saying that the PartitionKey extracted from the document (which should be the above document) doesn't match the one in the header. Well, isn't the header listed in the document?
Any help appreciated!
Thanks!
PartitionKey extracted from document doesn't match the one specified
in the header
This error causes by your partition key value in your connector isn't the same as the value in your document. In your case, your partition key is /salesNumber, so your partition key value in your connector should be "LXG995", not 'salesNumber'(with double-quotes around it).
What the problem was, was that the document I was putting into the container had salesNumber in the item/headers/salesnumber hierarchy. Not being up to speed on how Cosmos does thing, I just thought that it would insert that piece of data into the record as the partition key.
I discovered however that I had to make my partition key 'item/headers/salesNumber' instead of just '/salesNumber'.
I did need to use salesNumber as the partition key to account for the fact that their could be multiple orders from this customer, identified by their salesNumber.
Thanks!

Suddenly getting intermittent error "Failed to parse Dialogflow response into AppResponse : null"

I've suddenly recently started seeing errors like "Failed to parse Dialogflow response into AppResponse : null" on Actions On Google/Dialogflow projects that previously worked ok.
Even now, the error seems intermittent, and happens despite the response from my Firebase function (fulfilment webhook) being identical. In other words, sometimes I get the above error, and other times it works, but the response from my Firebase function is identical in both cases.
As an example, here is a response that sometimes, but not always, causes the error I mention above:
{ "status": 200, "headers": { "content-type":
"application/json;charset=utf-8" }, "body": { "payload": { "google": {
"expectUserResponse": true, "systemIntent": { "intent":
"actions.intent.OPTION", "data": { "#type":
"type.googleapis.com/google.actions.v2.OptionValueSpec", "listSelect":
{ "title": "Please select one option:", "items": [ { "optionInfo": {
"key": "Yes", "synonyms": [ [ "Go", "Lets go", "Let's go", "Get
started", "Yes", "I am ready", "Start the survey", "Start", "1", "One"
] ] }, "description": " Start a new diary entry", "title": "1. Let's
Go" }, { "optionInfo": { "key": "Stop", "synonyms": [ [ "No", "Don't
continue", "No thanks", "Stop", "Stop the survey", "2", "Two" ] ] },
"description": " Don't make a new diary entry", "title": "1. Stop" } ]
} } }, "richResponse": { "items": [ { "simpleResponse": {
"textToSpeech": "Hi. It’s
nice to have you here and we look forward to discussing the food and
drink you give your baby.Let us know each time
you give them something to eat or drink.When you
are ready to start, say Let’s go.", "displayText":
"Hi. \n \nLet us know each time you give them something to eat or
drink. \n \nWhen you are ready to start, select Let’s go." } } ] },
"userStorage":
"{\"data\":{\"userId\":\"bb46f3f9-e522-2da0-7b3c-302a615d28e4\",\"unicomId\":\"danone2\"}}"
} } } }
So in the Firebase logs I can see the above being returned in all cases, but sometimes Google Assistant fails, and the Google Cloud logs show the "Failed to parse Dialogflow response into AppResponse : null" error, and other times, with the identical JSON returned by Firebase, it happily works.
I'm at a slight loss as to where to look further, if anyone has any pointers that'd be much appreciated, thanks!
I had a same problem. In my case, systemIntent in my response json was null and it caused this error. It worked fine before but recently It failed. I hope it helps someone.
Just to close this issue - turns out this was my fault, and the JSON response was contructed wrongly (the "synonyms" were enclosed in duplicate [[ and ]]). I believe Dialogflow was suddenly flagging this as an error, when previously it was more forgiving.
Anyway - fixing the JSON response has fixed the issue.

Resources