I need to change the Prodcode field on any jobs when the same field on the OrderDtl line is changed.
I can’t use widgets as JobHead not available so need to use custom code but not sure how to do this. Would appreciate any help
First add the job entry Assembly:
The code below should do what you are looking for. I haven’t tested it
var oldRow = ds.OrderDtl.FirstOrDefault(x => x.RowMod == "");
var updatedRow = ds.OrderDtl.FirstOrDefault(x => x.RowMod == "U");
if(oldRow != null && updatedRow != null){
//check if ProdCode has been updated
if(oldRow.ProdCode != updatedRow.ProdCode){
this.CallService<Erp.Contracts.JobEntrySvcContract>(
jobEntrySvc => {
try{
//get all job rows if needed
//bool morePages;
//JobEntryTableset jobDs = jobEntrySvc.GetRows("","","","","","","","","","","","","","","","","","","","","","","","","","","","", 0, 0 , out morePages);
JobEntryTableset jobDs = new JobEntryTableset();
// get the ralated job DS by jobNum
jobEntrySvc.GetByID(YOUR_JOBNUM); // i dont know how are the Orders and Job connected in your case, but get the jobnum from somewhere and paste it here
if(jobDs != null && jobDs.JobHead.Count != 0){
//set the related JobHead.ProdCode to the OrderDtl.ProdCode
jobDs.JobHead[0].ProdCode = updatedRow.ProdCode;
jobDs.JobHead[0].RowMod = "U";
jobEntrySvc.Update(ref jobDs);
}
}catch(Exception ex){
throw new BLException("Error in updating Job Field: " + ex);
}
}
);
}
}