How to Automatically Complete Task when Closing Case

Hi guys,

Our customer service department wants to start using tasks on our cases, but doesn’t want to get stuck with a long list of open tasks on closed cases. I’d like to have Epicor complete the top task automatically when I close the case. I’m new to calling other BO’s before, but think I have the basics. I’ve re-read the Advanced BPM’s EDU document, the extended Ed courses, and a few examples (1, 2, 3, 4), but I’m still really confused on how to update a task with an invoked BO method (we’re on 10.2.700, so I could do functions, but figured I’d start with BPM’s since I’m more comfortable…). Any advice is appreciated!

image

From what a gather from a trace:

  1. Create a BPM on HelpDesk’s OpenCloseCase method.
  2. Use a Invoke BO Method widget to call the Task.GetByID BO (to find the task to mark complete) and load into a data set. (I’m getting an error trying to join ttHDCase.HDCaseNum integer to dsTask1’s Key1 string)
  3. Setup variable to update the task fields. Do I use four Set Argument/Variable widget to set these variables? Or an Update Table by Query setter? or Fill Table by Query? Or Set BPM Data Fields? I’m very confused by these, and what the ‘right’ way is…
  4. Invoke BO Method to call Task.UpdateExt (why not Update, which only has a dataset parameter, vs the UpdateExt that also has the error handling)? Also had a warning on the variable for dsTask, so I set that to dsTask2, but I think that’s not right…

Need to set the task:

  • Complete = True
  • ReasonCode = SOL
  • TaskCompletePasswordIsValid = True
  • ReasonCodeHDDescription = SOLUTION COMPLETE
  • RowMod = U.

image

image

image

image

image

image

<tracePacket>
  <businessObject>Erp.Proxy.BO.TaskImpl</businessObject>
  <methodName>Update</methodName>
  <appServerUri>net.tcp://***masked***/</appServerUri>
  <returnType>System.Void</returnType>
  <localTime>11/12/2021 08:46:34:1230897 AM</localTime>
  <threadID>1</threadID>
  <correlationId>3e6d1dc7-10b8-4e5d-8318-109d295c7723</correlationId>
  <executionTime total="422" roundTrip="402" channel="0" bpm="0" bpmDataForm="0" other="20" />
  <retries>0</retries>
  <parameters>
    <parameter name="ds" type="Erp.BO.TaskDataSet">
      <TaskDataSet xmlns="http://www.epicor.com/Ice/300/BO/Task/Task" />
    </parameter>
  </parameters>
  <paramDataSetChanges>
    <paramDataSet name="ds" useDataSetNbr="0">
      <changedValue tableName="Task" rowState="Modified" rowNum="0" colName="Complete"><![CDATA[True]]></changedValue>
      <changedValue tableName="Task" rowState="Modified" rowNum="0" colName="ReasonCode"><![CDATA[SOL]]></changedValue>
      <changedValue tableName="Task" rowState="Modified" rowNum="0" colName="TaskCompletePasswordIsValid"><![CDATA[True]]></changedValue>
      <changedValue tableName="Task" rowState="Modified" rowNum="0" colName="ReasonCodeHDDescription"><![CDATA[SOLUTION COMPLETE]]></changedValue>
      <changedValue tableName="Task" rowState="Modified" rowNum="0" colName="RowMod"><![CDATA[U]]></changedValue>
    </paramDataSet>
  </paramDataSetChanges>
</tracePacket>

Gonna be honest here and say I TLDR’d most of that but, I just had to write a BPM to Update a Task so I’m attaching the code below. In my case I had the SysRowID of the Task I’m trying to update, but you can find the Keys in your query the way you are already doing it.

try {
  using(Ice.Assemblies.ServiceRenderer.GetService < Erp.Contracts.TaskSvcContract > (Db)) {
    var taskData = (from t in Db.Task where t.SysRowID == TaskSysRowID select t).FirstOrDefault();
    if (task != null) {
      TaskDataSet = task.GetByID("HDCase", taskData.Key1, taskData.Key2, taskData.Key3, taskData.TaskSeqNum);
      Erp.Tablesets.TaskRow bufferRow = new Erp.Tablesets.TaskRow();
      BufferCopy.Copy(TaskDataSet.Task.FirstOrDefault(), bufferRow);
      TaskDataSet.Task.Add(bufferRow);
      TaskDataSet.Task.FirstOrDefault().RowMod = "U";

      string cMessage;
      task.ChangeComplete(ref TaskDataSet, true, out cMessage);
      ErrorMessage = cMessage;
      TaskDataSet.Task.FirstOrDefault().ReasonCode = "APPROVED";
      task.Update(ref TaskDataSet);
      //ErrorMessage = $"Sucess. TaskDataSet.Task.Count(): {TaskDataSet.Task.Count()}";
      Success = true;
    } else {
      Success = false;
      ErrorMessage = "Task not found";
    }

  }
  catch (Exception ex) {
    Success = false;
    ErrorMessage = ex.ToString();
  }
}
3 Likes

treated to know why do you create buffercopy @josecgomez

1 Like

Because the task business objects expects a before image to be present, without it, it can error out since some of Epicor’s own logic checks which fields changed.

1 Like

Great question @prakash .

I’ll go a step further and ask how you knew it expected something before it.

What was it that told you that it needed a before and after?

1 Like