Delete demand link by BPM

I created a persistent method using JobEntry BO to delete a demand link for Job Entry by changing the RowMod to D and executing the Update. The JobProd table is deleted however the ProdQty in JobHead keeps the qty. If I delete the demand manually the JobHead.ProdQty changes to zero, has anyone faced that problem or am I missing something?

PS. the only method that is triggered when deleting is the update.

What does your code look like? Are you invoking the BO?

Yes I’m invoking the BO, this is the code (I hard coded the Job Num for testing):

Erp.Contracts.JobEntrySvcContract hJob = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.JobEntrySvcContract>(Db);
Erp.Tablesets.JobEntryTableset jobDataSet = new Erp.Tablesets.JobEntryTableset();
if (hJob != null)
{

 jobDataSet = hJob.GetByID("2025");
 
 var jobProdRow = (from row in jobDataSet.JobProd
                   where row.Company == Session.CompanyID && row.JobNum == "2025"
                   select row).FirstOrDefault();
 if (jobProdRow != null)
 {
      jobProdRow.RowMod = "D"; //  Deleting the make to stock demand link 
      hJob.Update(ref jobDataSet);
 }

}
hJob = null;

Not sure if this will make a difference or not, but instead of using RowMod=“D”
Try setting the RowState

jobProdRow.SetRowState(IceRowState.Deleted);
1 Like

Have you tried updating the jobprod quantity yourself on the jobhead table add setting its rowmod to u in the same dataset?

(I’m on mobile so haven’t checked if it is in fact a field in the jobhead table)

It would also be in the JobAssembly table and the Material Labor, Costs etc calculations would be off. Updating the field in the DB wouldn’t fix those things in my experience.

It would be passed through the business logic so wouldn’t that take care of things? Having said that I assumed that deleting the demand link would have done the same.

Ah yeah, however I don’t believe that that field is updatable (directly) in Jobhead (I may be wrong)

Probably not, if the above code is mimicking what’s happening in the trace then I’ll just shrug

Thank you @josecgomez and @Ben_Bowtell, setting the rowstate did the trick.

Thanks again!