We are attempting to move our revision process into Epicor, using ECO and tasks. One of our primary goals is to ensure that certain steps, which aren’t always or even often required, get done when they ARE needed. So instead of cluttering the task set with a load of tasks that everyone will get used to ignoring, we only want to generate them when the results of earlier tasks make it appropriate.
When certain tasks are completed, an option is chosen from a drop-down (like “No released jobs” or “Jobs on floor”) that determines the creation of new tasks, immediately and/or after a milestone creation later in the task set. The options are stored in UD100 (“results”) and the new tasks to generate are stored in UD100A (“outcomes”).
Most of my experiments have caused infinite loops of task-creation, so I’m pleased to report my progression to a BPM-halting error instead. The error is the “another user changed this data” one, and it’s thrown when more than one task has to be created. If I break the loop after one run, everything works fine. Here’s the code that runs in Task.Update post-process after an eligible task is completed:
var svc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.TaskSvcContract>(Db);
// get the set of new tasks to create, based on the completed task, the chosen result, and the current stage
var newtask = from task in ttTask
join outcome in Db.UD100A
on new {task.Company, id = task.TaskID, result = task.UDField<System.String>(“Result_c”).ToString()}
equals new {outcome.Company, id = outcome.Key1.ToString(), result = outcome.Key2.ToString()}
join eco in Db.ECOGroup
on new {outcome.Company, stage = outcome.ShortChar03.ToString()}
equals new {eco.Company, stage = eco.CurrentWFStageID.ToString()}
where outcome.CheckBox01 == true && task.Key1.ToString() == eco.GroupID.ToString()select new {task.RelatedToFile, task.Key1, task.Key2, task.Key3, outcome.ShortChar01, outcome.ShortChar02, outcome.ShortChar03};
// this.newds is a TaskTableset variable
// Get a new task row, set required fields, run ChangeTaskID to populate the rest, and update to save
// If I break this loop after a single run, everything is dandy
foreach (var row in newtask) {
svc.GetNewTask(ref this.newds, row.RelatedToFile, row.Key1, row.Key2, row.Key3);
this.newds.Task.Last<Erp.Tablesets.TaskRow>().Company = “GI”;
this.newds.Task.Last<Erp.Tablesets.TaskRow>().TaskID = row.ShortChar01;
this.newds.Task.Last<Erp.Tablesets.TaskRow>().SalesRepCode = row.ShortChar02;
svc.ChangeTaskID(ref this.newds);
svc.Update(ref this.newds);
}
I assume the problem has something to do with when the update runs. I’ve tried moving that out of the loop, and moving both ChangeTaskID and Update out of the loop. No go.
I have a handful of message boxes for debugging in this and related directives, but not a single one appears when the changed data error happens – not even messages in the pre-process directive that enables THIS directive.
Can anyone shed some light on what the conflict is? Or maybe how to call that ServiceRenderer in Visual Studio so I can debug properly?