Function RecallFromApproval

Does anyone have working solution for this? Everything works up to recall it jus does nothing. When i do the same in UI it works, but not in function, no error, just nothing happens

this.CallService<Ice.Contracts.DynamicQuerySvcContract>(dqa =>
{
    var query = dqa.GetByID("PCTA_FollowersDtl");
    var parameters = dqa.GetQueryExecutionParametersByID("PCTA_FollowersDtl");

    TeamDtlDataSet = dqa.Execute(query, parameters);
});

int endedAct = 0;

foreach (DataRow employee in TeamDtlDataSet.Tables["Results"].Rows)
{
    string EmpID = employee["UD07_Key1"].ToString();
    string EmpPm = employee["UD07_Key3"].ToString();
    string EmpJobNum = employee["LaborDtl_JobNum"].ToString();

        if (Pm.ToString() == EmpPm && Pm.ToString() != EmpID && PmJob.ToString() == EmpJobNum)
        {
            try
            {
                int empLaborHedSeq = (int)employee["LaborDtl_LaborHedSeq"];
                int empLaborDtlSeq = (int)employee["LaborDtl_LaborDtlSeq"];

                this.CallService<Erp.Contracts.LaborSvcContract>(la =>
                {
                    Erp.Tablesets.LaborTableset laborTs =
                        new Erp.Tablesets.LaborTableset();

                    string vMessage = "";
                    string opMessage = "";
                    string pcMsg = "";
                    string cMessageText = "";

                    var laborDs = la.GetDetail(empLaborHedSeq, empLaborDtlSeq);
                    laborDs.LaborDtl[0].RowMod = "U";
                    la.EndActivity(ref laborDs);
                    la.DefaultLaborQty(ref laborDs, 0, out vMessage);
                    la.CheckWarnings(ref laborDs, out vMessage);
                    la.Update(ref laborDs);

                    laborDs = la.GetDetail(empLaborHedSeq, empLaborDtlSeq);
                    laborDs.LaborDtl[0].TimeStatus = "E";
                    laborDs.LaborDtl[0].RowMod = "U";
                    la.RecallFromApproval(ref laborDs, false, out cMessageText);
                    laborDs.LaborDtl[0].BurdenHrs = 0;
                    laborDs.LaborDtl[0].RowMod = "U";
                    la.Update(ref laborDs);
                    laborDs.LaborDtl[0].RowMod = "U";
                    la.ValidateChargeRateForTimeType(ref laborDs, out vMessage);
                    la.SubmitForApproval(ref laborDs, false, out cMessageText);
                    la.Dispose();
                    endedAct++;
                });
            }
            catch (Exception ex)
            {
                continue;
            }

        }

This works, but i dont understand why do i need to use second svc call.

foreach (DataRow employee in TeamDtlDataSet.Tables["Results"].Rows)
{
    string EmpID = employee["UD07_Key1"].ToString();
    string EmpPm = employee["UD07_Key3"].ToString();
    string EmpJobNum = employee["LaborDtl_JobNum"].ToString();

        if (Pm.ToString() == EmpPm && Pm.ToString() != EmpID && PmJob.ToString() == EmpJobNum)
        {
            try
            {
                int empLaborHedSeq = (int)employee["LaborDtl_LaborHedSeq"];
                int empLaborDtlSeq = (int)employee["LaborDtl_LaborDtlSeq"];

                this.CallService<Erp.Contracts.LaborSvcContract>(la =>
                {
                    Erp.Tablesets.LaborTableset laborTs =
                        new Erp.Tablesets.LaborTableset();

                    string vMessage = "";
                    string opMessage = "";
                    string pcMsg = "";
                    string cMessageText = "";

                    var laborDs = la.GetDetail(empLaborHedSeq, empLaborDtlSeq);
                    laborDs.LaborDtl[0].RowMod = "U";
                    la.EndActivity(ref laborDs);
                    la.DefaultLaborQty(ref laborDs, 0, out vMessage);
                    la.CheckWarnings(ref laborDs, out vMessage);
                    la.Update(ref laborDs);
                    la.Dispose();
                });
                this.CallService<Erp.Contracts.LaborSvcContract>(laRec =>
                {
                    Erp.Tablesets.LaborTableset laborTs =
                        new Erp.Tablesets.LaborTableset();

                    string vMessage = "";
                    string opMessage = "";
                    string pcMsg = "";
                    string cMessageText = "";


                    
                    var laborDsRec = laRec.GetDetail(empLaborHedSeq, empLaborDtlSeq);
                    laborDsRec.LaborDtl[0].TimeStatus = "E";
                    laborDsRec.LaborDtl[0].RowMod = "U";
                    laRec.RecallFromApproval(ref laborDsRec, false, out cMessageText);
                    laborDsRec.LaborDtl[0].BurdenHrs = 0;
                    laborDsRec.LaborDtl[0].RowMod = "U";
                    laRec.Update(ref laborDsRec);
                    //laborDs.LaborDtl[0].RowMod = "U";
                    //la.ValidateChargeRateForTimeType(ref laborDs, out vMessage);
                    //la.SubmitForApproval(ref laborDs, false, out cMessageText);
                    
                    laRec.Dispose();
                    output2 = laborDsRec;
                    
                    endedAct++;
                });
            }

When Kinetic makes REST calls, the server doesn’t remember anything from prior interactions (hence it being stateless). When a request is received, it’s handled it with a “fresh” service, it’s not going to keep the same one waiting around for your next request. That’s why you pass data sets back and forth, as that’s your state.

This isn’t true when you use CallService. BOs have internal tablesets that you can’t directly manage and will persist until the service is disposed.

My guess is that GetDetail could be adding rows to the tableset, keeping the old ones as well. Maybe the service is working on row 1 when you make subsequent calls, but your code is working on row 2. Using the same calls from REST doesn’t have the issue because the old rows weren’t remembered.

Yes when i call GetDetail again i see 2 rows of LaborDtl and no mater with which one i work, recall does not work. So in this case it is good that i dispose first svc and call new? Since then i see one LaborDtl row

Yeah this is the BO holding state. Genoah’s right.

When you do it all in one CallService the Labor BO keeps its internal tableset. So you GetDetail, EndActivity, Update, and the row gets saved (SysRevID changes, and if auto submit is on TimeStatus goes to S). Then you GetDetail again on the same instance and it doesnt replace the row, it adds another one. Thats your 2 LaborDtl rows.

RecallFromApproval then looks at the stale copy, decides theres nothing to recall and just returns. No error, nothing happens. REST and the UI dont hit this cos every call is a fresh instance.

So splitting it is the actual fix, not a hack. I’d do it like this, with one row and a fresh instance for each step:

foreach (var r in followers)   // rows from PCTA_FollowersDtl
{
    int hedSeq = r.LaborDtl_LaborHedSeq;
    int dtlSeq = r.LaborDtl_LaborDtlSeq;

    // 1) end activity
    this.CallService<Erp.Contracts.LaborSvcContract>(svc =>
    {
        var ds = svc.GetDetail(hedSeq, dtlSeq);
        ds.LaborDtl.RemoveAll(d => d.LaborDtlSeq != dtlSeq);
        ds.LaborDtl[0].RowMod = "U";
        svc.EndActivity(ref ds);
        svc.Update(ref ds);
    });

    // 2) new instance, recall + resubmit
    this.CallService<Erp.Contracts.LaborSvcContract>(svc =>
    {
        var ds = svc.GetDetail(hedSeq, dtlSeq);
        ds.LaborDtl.RemoveAll(d => d.LaborDtlSeq != dtlSeq);
        var dtl = ds.LaborDtl[0];

        if (dtl.TimeStatus != "S") return;   // only submitted can be recalled

        string msg;
        dtl.RowMod = "U";
        svc.RecallFromApproval(ref ds, false, out msg);

        // do your changes here

        ds.LaborDtl[0].RowMod = "U";
        svc.SubmitForApproval(ref ds, false, out msg);
    });
}

Couple of things:

  • dont reuse the Labor BO across an Update. new CallService each time
  • trim the ds down to the one row and set RowMod = “U” on it, otherwise it gets ignored without an error
  • check TimeStatus first. if its A (approved) recall wont do anything, and if its still E theres nothing to recall
  • if it still does nothing, F12 the Time Entry screen while you hit Recall and compare the LaborDtl row the UI sends with yours. copy whatever flags it sets

Also, if youre only recalling because Update auto submits after end activity, you can probably skip all this. Do your edits before the first Update, or turn off auto submit for that labour type.

Recalling only because of this laborDsRec.LaborDtl[0].BurdenHrs = 0; :sweat_smile: Because i can not set before end activity update. It recalculates