Automating DMT PO receipt Combined

I am trying to automate the DMT PO receipt Combined Process. The route I’ve been taking is using Power Automate and then calling an API that runs a function. I convert the json Data into Erp.Tablesets.UpdExtReceiptTableset using a custom code function and then call the Erp.Receipt.UpdateExt BO Method to submit the data.

What’s going wrong is when the data is sent to the BO Method caller… Here is a snippet of what I am receiving back as the API response:

{
  "Errors": {
    "BOUpdError": [
      {
        "TableName": "RcvHead",
        "ErrorLevel": "Error",
        "ErrorType": "Exception",
        "ErrorText": "A valid Packing Slip is required.\r\nSupplier Number is required.\r\nPacking Slip is required.",
        "ErrorSysRowID": "00000000-0000-0000-0000-000000000000",
        "SysRowID": "509e98ce-aa0c-4eef-8fb2-dbe33dd5adc4",
        "RowMod": ""
      }
    ],
    "ExtensionTables": []
  },
  "DataSet": {
    "RcvHead": [
      {
        "Company": "PERL01",
        "VendorNum": 0,
        "PurPoint": "",
        "PackSlip": "",
        "ReceiptDate": null,

The custom code function is returning a tableset that has populated data, as shown below:

{
  "data": {
    "RcvHead": [
      {
        "Company": "PERL01",
        "VendorNum": 69,
        "PurPoint": "1",
        "PackSlip": "33019-2500",
        "ReceiptDate": "2023-08-20T16:06:17.14Z",

I went to the trace logging file to monitor the Update Ext Profile and noticed that the data is being taken in by the system but once it notices that a record doesn’t exist to update, it tries to create a new record with an empty dataset (using none of the data I submitted). Hence why I’m getting the errors I’m getting.

Would anyone know why this is happening?

Hi Christopher,

I’m just putting this out there because I have struggled with DMTing the vendor ID on the PartPlant records. It would not provide an error/message but failed uploading via DMT. I needed to provide both VendorNum and VendorID but needed to call that VendorNumVendorID. Any chance you have a fail due to the vendor not getting uploaded properly?

Nancy

Hi Nancy,

thanks for the response…

I believe that I am taking care of that part in the custom code function that I built where I query the database to get the vendorNum by VendorID… see coding below:

  switch(this.typeOfDmt)
  {
      case "PO Receipt Combined":
        
        // Search Vendors to find the correct VendorNum
        var vendorNums = (from h in Db.Vendor where h.VendorID == this.vendorId select h.VendorNum);

        // Add the VendorNum to the DataSet and Update the RowMod fields to "A" for add
        JObject obj = JsonConvert.DeserializeObject<JObject>(this.jsonData);       
        obj["RcvHead"][0]["VendorNum"] = vendorNums.First();
        obj["RcvHead"][0]["RowMod"] = "A";  //coworker thought I needed this
        obj["RcvDtl"][0]["RowMod"] = "A";  //coworker thought I needed this
        
        // Convert the dataset to The proper Business Object for loading
        this.data = JsonConvert.DeserializeObject<Erp.Tablesets.UpdExtReceiptTableset>(obj.ToString());
        
      break;
  }

for a bit more insight… this is the type of data that I am feeding the system from the API call through Power Automate:

{
  "jsonData": "{
	  "RcvHead": [
		{
		  "Company": "PERL01",
		  "Plant": "P01",
		  "VendorNum": null,
		  "PackSlip": "33019-2500",
		  "PONum": 259414,
		  "POType": "SMI",
		  "VendorNumVendorID": "ENDR001",
		  "PurPoint": "1",
		  "ReceivePerson": "DMT",
		  "ReceiptDate": "2023-08-20T16:06:17.140Z",
		  "RowMod": null
		}
	  ],
	  "RcvDtl": [
		{
		  "Company": "PERL01",
		  "Plant": "P01",
		  "ReceiptType": "P",
		  "PONum": 259414,
		  "POLine": 11,
		  "PORelNum": 1,
		  "PackLine": 0,
		  "PartNum": "54974-1",
		  "InputOurQty": 4000,
		  "IUM": "EA",
		  "ReceivedTo": "PUR-STK",
		  "Received": true,
		  "ReceiptDate": "2023-08-20T16:06:17.140Z",
		  "RowMod": null
		}
	  ]
	}",
  "typeOfDmt": "PO Receipt Combined",
  "vendorId": "ENDR001"
}

Here is the tracing log when I run the update ext. Any help would be extremely useful, thanks.
Debug.txt (63.5 KB)