Just wondering if anyone has any insight on this… I’m trying to create a new rcvDtl row in a custom epicor function, I call an api that feeds json data to the function that looks like this:
{
"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”
}
],
“RcvDtl”: [
{
“ReceiptType”: “P”,
“POLine”: 11,
“PORelNum”: 1,
“PackLine”: 0,
“PartNum”: “54974-1”,
“InputOurQty”: 4000,
“IUM”: “EA”,
“ReceivedTo”: “PUR-STK”,
“Received”: true
}
]
}",
"typeOfDmt": "PO Receipt Combined"
}
I can add a new rcvHead line just fine by itself, but when I try to add a new rcvDtl line that is tied to it, I get an error that states this: Packing Slip referenced is not for this site.
Here is my code:
{
switch(this.typeOfDmt)
{
case "PO Receipt Combined":
var context = Ice.Services.ContextFactory.CreateContext<ErpContext>();
JObject jobj = JsonConvert.DeserializeObject<JObject>(this.jsonData);
string vendorId = jobj["RcvHead"][0]["VendorNumVendorID"].ToString();
//Erp.BO.UpdExtReceiptDataSet dsRecUpdExt = new Erp.BO.UpdExtReceiptDataSet();
using( var receiptSvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.ReceiptSvcContract>(context)){
// Search Vendors to find the correct VendorNum
int vendorNums = (from h in Db.Vendor where h.VendorID == vendorId select h.VendorNum).FirstOrDefault();
bool errorsOccurred = false;
var rcvHdRow = new Erp.Tablesets.RcvHeadRow(){
Company = (string)jobj["RcvHead"][0]["Company"],
Plant = (string)jobj["RcvHead"][0]["Plant"],
VendorNum = vendorNums,
PackSlip = (string)jobj["RcvHead"][0]["PackSlip"],
PONum = (int)jobj["RcvHead"][0]["PONum"],
POType = (string)jobj["RcvHead"][0]["POType"],
VendorNumVendorID = (string)jobj["RcvHead"][0]["VendorNumVendorID"],
PurPoint = (string)jobj["RcvHead"][0]["PurPoint"],
ReceivePerson = (string)jobj["RcvHead"][0]["ReceivePerson"],
ReceiptDate = DateTime.Parse(jobj["RcvHead"][0]["ReceiptDate"].ToString())
};
var rcvDtlRow = new Erp.Tablesets.RcvDtlRow(){
Company = (string)jobj["RcvHead"][0]["Company"],
Plant = (string)jobj["RcvHead"][0]["Plant"],
VendorNum = vendorNums,
PackSlip = (string)jobj["RcvHead"][0]["PackSlip"],
ReceiptType = (string)jobj["RcvDtl"][0]["ReceiptType"],
PONum = (int)jobj["RcvHead"][0]["PONum"],
POLine = (int)jobj["RcvDtl"][0]["POLine"],
PORelNum = (int)jobj["RcvDtl"][0]["PORelNum"],
PackLine = (int)jobj["RcvDtl"][0]["PackLine"],
PartNum = (string)jobj["RcvDtl"][0]["PartNum"],
InputOurQty = (int)jobj["RcvDtl"][0]["InputOurQty"],
IUM = (string)jobj["RcvDtl"][0]["IUM"],
ReceivedTo = (string)jobj["RcvDtl"][0]["ReceivedTo"],
Received = (bool)jobj["RcvDtl"][0]["Received"],
PurPoint = (string)jobj["RcvHead"][0]["PurPoint"],
ReceiptDate = DateTime.Parse(jobj["RcvHead"][0]["ReceiptDate"].ToString())
};
//var getRecord = receiptSvc.GetByID(vendorNums, jobj["RcvHead"][0]["PurPoint"].ToString(), jobj["RcvHead"][0]["PackSlip"].ToString());
this.data.RcvHead.Add(rcvHdRow);
this.data.RcvHead.RcvHeadToRcvDtlRelation.ChildTable.Add(rcvDtlRow);
this.errors = receiptSvc.UpdateExt(ref this.data, false, true, out errorsOccurred);
}
break;
}
}
Any help would be greatly appreacited!