I have a situation where I want a BPM on the JobEntry.Update method to fire as a result of code running in a BPM on the Project.Update method.
I have four BPMs total. Pre and Post processing on both the JobEntry.Update and Project.Update methods.
JobEntry.Update
Pre-Processing: If JobOnHold_c is changed from false to true, enable post-processing BPM.
Post-Processing: Clear the JobEngineered flag, remove from schedule.
Project.Update
Pre-Processing: If ProjectOnHold_c is changed from false to true, enable post-processing BPM.
Post-Processing: Get the list of open and engineered jobs that are related to the project. Loop through them, setting JobOnHold_c to true, RowMod = U, and call the JobEntry.Update method.
Individually, both pairs of BPMs work as expected. However, the JobEntry.Update BPMs are not triggered when JobEntry.Update is called from the Project.Update BPM.
Is this normal behavior? I thought a BPM is executed on a method call no matter where it is called from. What am I missing? Let me know if I can provide any other info.
Project.Update BPM Code:
var project = ds.Project.FirstOrDefault();
if (project != null)
{
var jobEntry = ServiceRenderer.GetService<Erp.Contracts.JobEntrySvcContract>(Db);
var company = project.Company;
var projectID = project.ProjectID;
var jobNums = Db.JobHead.Where(job => job.Company == company && job.ProjectID == projectID && !job.JobClosed && !job.JobComplete && job.JobEngineered).Select(job => job.JobNum).ToList();
foreach (var jobNum in jobNums)
{
var jobDS = jobEntry.GetByID(jobNum);
var jobHead = jobDS.JobHead.First();
jobHead["JobOnHold_c"] = true;
jobHead.RowMod = "U";
jobEntry.Update(ref jobDS);
}
}
To clarify, the above code does run successfully (JobOnHold_c is set to true), but the BPM attached to the JobEntry.Update method (that I am calling in this code) does not.
Thanks