Hello, we have BPM that triggers off the AppendDetails that deletes unused future operations. Works great. I’m trying to move this functionality to function and I’m not able to do the same thing.
Here is what I have in the BPM
using (var txScope = IceDataContext.CreateDefaultTransactionScope()) {
foreach (var JobOperRow in (from JobOper_Row in Db.JobOper.With(LockHint.UpdLock)
where JobOper_Row.Company == Session.CompanyID
&& JobOper_Row.JobNum == targetJob
&& JobOper_Row.OprSeq >= targetOpr
select JobOper_Row).OrderByDescending(x => x.OprSeq)) {
Db.JobOper.Delete(JobOperRow);
}
Db.Validate();
txScope.Complete();
}
I can’t use this in the function because Db.JobOper.Delete doesn’t exist.
I’ve tried Db.DeleteObject(JobOperRow) but it doesn’t appear to do anything.
I’ve tried deleting the row from the dataset and updating, but while I receive no errors it also doesn’t delete anything.
using (var txScope = IceDataContext.CreateDefaultTransactionScope()) {
this.CallService<Erp.Contracts.JobEntrySvcContract>(jSvc => {
Erp.Tablesets.JobEntryTableset jobDataSet = new Erp.Tablesets.JobEntryTableset();
jobDataSet = jSvc.GetByID(targetJob);
foreach (var JobOperRow in (from row in jobDataSet.JobOper
where row.OpCode >= targetOpr
select row)) {
// Tried setting RowMod as well
JobOperRow.RowMod = "D";
jobDataSet.JobOper.RemoveAll(x => x.OprSeq == JobOperRow.OprSeq);
}
jSvc.Update(ref jobDataSet);
});
txScope.Complete();
}
The function DB access is set to readwrite and the JobOper table is marked updateable. I have no problem adding operations, resources, material to the job so I know the table is updateable.
Can anyone enlighten what is the proper way to delete records from within a function?