can anyone point on how can i update ud field in partplant from standard data directive? Do i need to write it directly in db or i can do it this way by adjusting some script. I can not figure out.
foreach(var line in poDs.PODetail)
{
var svcpart = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.PartSvcContract>(this.Db); // Get service contract
var partDs = svcpart.GetByID(line.PartNum);
var partDetails = partDs.Part.FirstOrDefault();
var partPlantDetails = partDs.PartPlant.FirstOrDefault();
if(partDetails.UserInteger1 > 0 && (bool)partPlantDetails["Inspection_c"] == true)
{
partDetails.UserInteger1 = partDetails.UserInteger1 - 1;
if(partDetails.UserInteger1 < 1 && (bool)partPlantDetails["Inspection_c"] == true)
{
partPlantDetails["Inspection_c"] = false;
partDetails.RowMod = "U";
partPlantDetails.RowMod = "U";
}
else
{
partDetails.RowMod = "U";
}
svcpart.Update(ref partDs);
}
svcpart.Dispose();
}
svc.Dispose(); // realease Service Contract
we have custom bool in part table when we set it to true, userinteger1 in part table is set to 3 and bpm sets inspection required on PO line if PO created for that part. we need to set custom bool for related parts in part table to false when 3 PO orders are closed, this is totally custom process.
I’ve always seen this as SetUDField<System.[Data Type]> … is it not necessary to specify the type? or is that just for when the type may not be obvious to the compiler?
Necessary? No. But a good practice for sure as you will get a compiler warning if you have a type mismatch. Otherwise you don’t get it until runtime and it’s a lot harder to debug.
I would have to test to be sure, but I don’t think you can update 2 rows at a time. Just update one row (the partPlantDetails) and try that. I suspect having 2 updated rows is what’s giving you the problem. When you need 2 different things updated, you probably need to do one row, update, then the other row, update again.
Are you following a trace? Make sure you follow the methods the same as the trace.
I think so, the only thing that I do not see in trace is U state of RowMod. It is empty, only UD field value changes when I do this manualy. Do I need to skip RowMod?