UBAQ updating multiple tables

I have a UBAQ that updates dates on multiple tables. I have created a custom update method that works and has been in production for a while now. It currently handles updates to OrderHed, OrderDtl, OrderRel and JobHead. I want to add an update to JobOper as well, updating DaysOut field. I added a few lines to update JobOper, it runs without error, but everything get updated except JobOper.DaysOut. I am missing something?

try
{
    var hSalesOrder = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.SalesOrderSvcContract>(Db);
    var hJobEntry   = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.JobEntrySvcContract>(Db);

    // Only work rows that are not processed and have a RowMod
    var resultQuery = queryResultDataset.Results.Where(r => !string.IsNullOrEmpty(r.RowMod) && r.RowMod != "P");

    foreach (var ttResult in resultQuery)
    {
        bool anySuccess = false;

        // -------------------------
        // Sales Order block
        // -------------------------
        if (hSalesOrder != null
            && (ttResult.OrderHed_OrderNum > 0 || ttResult.OrderDtl_OrderNum > 0 || ttResult.OrderRel_OrderNum > 0))
        {
            var dsSO = new Erp.Tablesets.UpdExtSalesOrderTableset();

            // OrderHed
            if (ttResult.OrderHed_OrderNum > 0)
            {
                var hed = new Erp.Tablesets.OrderHedRow();
                hed.Company  = ttResult.OrderHed_Company;
                hed.OrderNum = ttResult.OrderHed_OrderNum;

                if (ttResult.OrderHed_NeedByDate > DateTime.MinValue)   hed.NeedByDate   = ttResult.OrderHed_NeedByDate;
                if (ttResult.OrderHed_RequestDate > DateTime.MinValue)  hed.RequestDate  = ttResult.OrderHed_RequestDate;

                hed.RowMod = "U";
                dsSO.OrderHed.Add(hed);
            }

            // OrderDtl
            if (ttResult.OrderDtl_OrderNum > 0 && ttResult.OrderDtl_OrderLine > 0)
            {
                var dtl = new Erp.Tablesets.OrderDtlRow();
                dtl.Company   = ttResult.OrderDtl_Company;
                dtl.OrderNum  = ttResult.OrderDtl_OrderNum;
                dtl.OrderLine = ttResult.OrderDtl_OrderLine;

                if (ttResult.OrderDtl_NeedByDate > DateTime.MinValue)   dtl.NeedByDate   = ttResult.OrderDtl_NeedByDate;
                if (ttResult.OrderDtl_RequestDate > DateTime.MinValue)  dtl.RequestDate  = ttResult.OrderDtl_RequestDate;

                dtl.RowMod = "U";
                dsSO.OrderDtl.Add(dtl);
            }

            // OrderRel
            if (ttResult.OrderRel_OrderNum > 0 && ttResult.OrderRel_OrderLine > 0 && ttResult.OrderRel_OrderRelNum > 0)
            {
                var rel = new Erp.Tablesets.OrderRelRow();
                rel.Company     = ttResult.OrderRel_Company;
                rel.OrderNum    = ttResult.OrderRel_OrderNum;
                rel.OrderLine   = ttResult.OrderRel_OrderLine;
                rel.OrderRelNum = ttResult.OrderRel_OrderRelNum;

                if (ttResult.OrderRel_NeedByDate > DateTime.MinValue)   rel.NeedByDate   = ttResult.OrderRel_NeedByDate;
                if (ttResult.OrderRel_ReqDate    > DateTime.MinValue)   rel.ReqDate      = ttResult.OrderRel_ReqDate;

                rel.RowMod = "U";
                dsSO.OrderRel.Add(rel);
            }

            // Only call UpdateExt if we actually queued a row
            if (dsSO.OrderHed.Count > 0 || dsSO.OrderDtl.Count > 0 || dsSO.OrderRel.Count > 0)
            {
                bool soError;
                BOUpdErrorTableset soErrs = hSalesOrder.UpdateExt(ref dsSO, true, true, out soError);

                if (soError && soErrs != null && soErrs.BOUpdError != null && soErrs.BOUpdError.Count > 0)
                {
                    string msg = Convert.ToString(soErrs.BOUpdError[0]["ErrorText"]);
                    this.PublishInfoMessage("SalesOrder.UpdateExt: " + msg,
                        Ice.Common.BusinessObjectMessageType.Error, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
                }
                else
                {
                    anySuccess = true;
                }
            }
        }

        // -------------------------
        // Job block
        // -------------------------
        if (hJobEntry != null && !string.IsNullOrEmpty(ttResult.JobHead_JobNum))
        {
            var dsJob = new Erp.Tablesets.UpdExtJobEntryTableset();

            var jh = new Erp.Tablesets.JobHeadRow();
            jh.Company = ttResult.JobHead_Company;
            jh.JobNum  = ttResult.JobHead_JobNum;
            jh.JobEngineered = ttResult.JobHead_JobEngineered;
            jh.JobReleased = ttResult.JobHead_JobReleased;
            jh.SchedCode = ttResult.JobHead_SchedCode;
            jh.SetUDField<System.Boolean>("ReadyForEngineering_c", ttResult.JobHead_ReadyForEngineering_c);

            if (ttResult.JobHead_ReqDueDate > DateTime.MinValue) jh.ReqDueDate = ttResult.JobHead_ReqDueDate;

            jh.RowMod = "U";
            dsJob.JobHead.Add(jh);

// --- New Code Block ------
            var jo = new Erp.Tablesets.JobOperRow();
            jo.Company = ttResult.JobHead_Company;
            jo.DaysOut  = ttResult.JobOper_DaysOut;

            jo.RowMod = "U";
            dsJob.JobOper.Add(jo);
// -------------------------

            bool jobError;
            BOUpdErrorTableset jobErrs = hJobEntry.UpdateExt(ref dsJob, true, true, out jobError);

            if (jobError && jobErrs != null && jobErrs.BOUpdError != null && jobErrs.BOUpdError.Count > 0)
            {
                string msg = Convert.ToString(jobErrs.BOUpdError[0]["ErrorText"]);
                this.PublishInfoMessage("JobEntry.UpdateExt: " + msg,
                    Ice.Common.BusinessObjectMessageType.Error, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
            }
            else
            {
                anySuccess = true;
            }
        }

        // Mark BAQ row as processed if at least one update succeeded
        if (anySuccess)
        {
            ttResult.RowMod = "P";
        }
    }

    // Clean up safely
    if (hSalesOrder != null) { hSalesOrder.Dispose(); hSalesOrder = null; }
    if (hJobEntry   != null) { hJobEntry.Dispose();   hJobEntry   = null; }
}
catch (Exception ex)
{
    this.PublishInfoMessage("BAQ BPM error: " + ex.Message,
        Ice.Common.BusinessObjectMessageType.Error, Ice.Bpm.InfoMessageDisplayMode.Individual, "", "");
}

You’re creating a row jo with Company and DaysOuts assigned, but no other key fields to tell Epicor which operation you want to modify.

You’ll need to also add JobNum, AssemblySeq, and OprSeq.

It’s been a long day, what was I thinking. Thanks

I have update the code and it still does not update.

            var jo = new Erp.Tablesets.JobOperRow();
            jo.Company = ttResult.JobOper_Company;
            jo.JobNum = ttResult.JobOper_JobNum;
            jo.AssemblySeq = ttResult.JobOper_AssemblySeq;
            jo.OprSeq = ttResult.JobOper_OprSeq;
            //jo.OpCode = ttResult.JobOper_OpCode;
            jo.DaysOut  = ttResult.JobOper_DaysOut;

            jo.RowMod = "U";
            dsJob.JobOper.Add(jo);
            callContextBpmData.Character01 += "--UpdateJobOper - DaysOut: " + jo.DaysOut.ToString() + "\n";

Might need a beforeimage

When doing child tables in UpdateExt you need to include the key fields for the hierarchy of parent tables as well.

You have Job head already however you are missing JobAssmbl. Add a row for that with its key fields set.

That was it. I forgot about that, when I originally wrote this I needed to include OrderHed, OrderDtl, and OrderRel in order to update OrderRel fields. Thanks