jgehling
(Jeff Gehling)
1
Hey Friends!
Super simple, I’m writing a function to update the primary bin on a part warehouse record. Here is my code:
var partTable = new Erp.Tablesets.PartTableset();
string myPartNum = PartNum;
string myWhseCode = ipWhseCode;
string myBinNum = ipPrimBinNum;
Action UpdatePart = () =>
{
CallService<Erp.Contracts.PartSvcContract>(partSvc =>
{
partTable = partSvc.GetByID(myPartNum);
var currentWhseRecord = partTable.PartWhse.FirstOrDefault();
currentWhseRecord.PrimBinNum = "outsource";
currentWhseRecord.RowMod = "U";
partSvc.Update(ref partTable);
});
};
UpdatePart();
Do I have to use a direct db update instead?

1 Like
Randy
(Randy Stulce)
2
I have a function that updates UD10 that’s very similar so

1 Like
jgehling
(Jeff Gehling)
3
Any ideas anyone? This is driving me crazy haha!

jgehling
(Jeff Gehling)
4
A direct Db update was the only way I could get this to stick…sigh.
Final Code:
string myPartNum = ipPartNum;
string myWhseCode = ipWhseCode;
string myBinNum = ipPrimBinNum;
Action UpdatePart = () =>
{
var partWhseRecord = Db.PlantWhse.With(LockHint.UpdLock).Where(w => w.WarehouseCode == "WH1" && w.Company == "myCompany" && w.PartNum == myPartNum && w.Plant == "MfgSys").FirstOrDefault();
partWhseRecord.PrimBin = ipPrimBinNum;
Db.SaveChanges();
};
UpdatePart();
1 Like
Hi Jeff,
I know you’ve solved this using a Db update, but it is possible using the Part BO methods.
Looks like you may have been trying to update the bin against a potentially different warehouse, I’ve seen this fall over silently before too.
You’d need to update the following line in your original post:
var currentWhseRecord = partTable.PartWhse.FirstOrDefault(pwh => pwh.WarehouseCode == myWhseCode);
Hope this helps future travellers!
Cheers,
Nathan
4 Likes