Sorry for the delay @bordway ,
I decided to try doing this in a simple example.
This is the BAQ:
One UD field in Customer table (SiteID_c) and two fields on OrderDtl table (NeedByDate and RequestDate).
First I checked the standard code for each one of these using a standard BPM in UBAQ. Here are the codes for each one:
OrderDtl update:
// <auto-generated>
// This code was generated by a tool. Any changes made manually will be lost
// the next time this code is regenerated.
// </auto-generated>
using (var updater = this.getDataUpdater("Erp", "SalesOrder"))
{
var ttResultQuery = ttResults
.Where(row => !string.IsNullOrEmpty(row.RowMod) && row.RowMod != "P");
foreach (var ttResult in ttResultQuery)
{
var ds = new Erp.Tablesets.UpdExtSalesOrderTableset();
// Query to object mapping
{
var OrderDtl = new Erp.Tablesets.OrderDtlRow
{
Company = Constants.CurrentCompany,
NeedByDate = ttResult.OrderDtl_NeedByDate,
//OpenLine = ttResult.OrderDtl_OpenLine,
OrderLine = ttResult.OrderDtl_OrderLine,
OrderNum = ttResult.OrderDtl_OrderNum,
RequestDate = ttResult.OrderDtl_RequestDate,
};
ds.OrderDtl.Add(OrderDtl);
var OrderHed = new Erp.Tablesets.OrderHedRow
{
Company = Constants.CurrentCompany,
//CurrencyCode = ttResult.OrderHed_CurrencyCode,
//ExchangeRate = ttResult.OrderHed_ExchangeRate,
//NeedByDate = ttResult.OrderHed_NeedByDate,
//OrderAmt = ttResult.OrderHed_OrderAmt,
OrderNum = ttResult.OrderHed_OrderNum,
};
ds.OrderHed.Add(OrderHed);
}
BOUpdErrorTableset boUpdateErrors = updater.Update(ref ds);
if (this.BpmDataFormIsPublished()) return;
ttResult.RowMod = "P";
// Object to query mapping
{
var OrderDtl = ds.OrderDtl.FirstOrDefault(
tableRow => tableRow.Company == Constants.CurrentCompany
&& tableRow.OrderLine == ttResult.OrderDtl_OrderLine
&& tableRow.OrderNum == ttResult.OrderDtl_OrderNum);
if (OrderDtl == null)
{
OrderDtl = ds.OrderDtl.LastOrDefault();
}
var OrderHed = ds.OrderHed.FirstOrDefault(
tableRow => tableRow.Company == Constants.CurrentCompany
&& tableRow.OrderNum == ttResult.OrderHed_OrderNum);
if (OrderHed == null)
{
OrderHed = ds.OrderHed.LastOrDefault();
}
if (OrderDtl != null)
{
ttResult.OrderDtl_NeedByDate = OrderDtl.NeedByDate;
//ttResult.OrderDtl_OpenLine = OrderDtl.OpenLine;
ttResult.OrderDtl_OrderLine = OrderDtl.OrderLine;
ttResult.OrderDtl_OrderNum = OrderDtl.OrderNum;
ttResult.OrderDtl_RequestDate = OrderDtl.RequestDate;
}
if (OrderHed != null)
{
//ttResult.OrderHed_CurrencyCode = OrderHed.CurrencyCode;
//ttResult.OrderHed_ExchangeRate = OrderHed.ExchangeRate;
//ttResult.OrderHed_NeedByDate = OrderHed.NeedByDate;
//ttResult.OrderHed_OrderAmt = OrderHed.OrderAmt;
ttResult.OrderHed_OrderNum = OrderHed.OrderNum;
}
}
if (boUpdateErrors?.BOUpdError?.Count > 0)
{
ttErrors
.AddRange(
boUpdateErrors.BOUpdError
.Select(
e => new ErrorsUbaqRow
{
TableName = e.TableName,
ErrorRowIdent = ttResult.RowIdent,
ErrorText = e.ErrorText,
ErrorType = e.ErrorType
}));
}
}
}
var ttResultsForDelete = ttResults.Where(row => row.RowMod != "P").ToArray();
foreach (var ttResult in ttResultsForDelete){ ttResults.Remove(ttResult);}
foreach (var ttResult in ttResults){ ttResult.RowMod = "";}
Customer Update:
// <auto-generated>
// This code was generated by a tool. Any changes made manually will be lost
// the next time this code is regenerated.
// </auto-generated>
using (var updater = this.getDataUpdater("Erp", "Customer"))
{
var ttResultQuery = ttResults
.Where(row => !string.IsNullOrEmpty(row.RowMod) && row.RowMod != "P");
foreach (var ttResult in ttResultQuery)
{
// Query to object mapping
{
var Customer = new Erp.Tablesets.CustomerRow
{
Company = ttResult.Customer_Company,
CustNum = ttResult.Customer_CustNum,
};
Customer.SetUDField<System.String>("SiteID_c", ttResult.Customer_SiteID_c);
dsCustomer.Customer.Add(Customer);
}
BOUpdErrorTableset boUpdateErrorsCustomer = updater.Update(ref dsCustomer);
if (this.BpmDataFormIsPublished()) return;
ttResult.RowMod = "P";
// Object to query mapping
{
var Customer = dsCustomer.Customer.FirstOrDefault(
tableRow => tableRow.Company == ttResult.Customer_Company
&& tableRow.CustNum == ttResult.Customer_CustNum);
if (Customer == null)
{
Customer = dsCustomer.Customer.LastOrDefault();
}
if (Customer != null)
{
ttResult.Customer_Company = Customer.Company;
ttResult.Customer_CustNum = Customer.CustNum;
ttResult.Customer_SiteID_c = Customer.UDField<System.String>("SiteID_c", throwIfNull:false);
}
//===================================================
}
if (boUpdateErrorsCustomer?.BOUpdError?.Count > 0 )
{
ttErrors
.AddRange(
boUpdateErrorsCustomer.BOUpdError
.Select(
e => new ErrorsUbaqRow
{
TableName = e.TableName,
ErrorRowIdent = ttResult.RowIdent,
ErrorText = e.ErrorText,
ErrorType = e.ErrorType
}));
}
}
}
var ttResultsForDelete = ttResults.Where(row => row.RowMod != "P").ToArray();
foreach (var ttResult in ttResultsForDelete){ ttResults.Remove(ttResult);}
foreach (var ttResult in ttResults){ ttResult.RowMod = "";}
Then in the updated BAQ switched to the Advanced BPM update:
And then clicked on the BPM Directives Configuration and added two base processings and one custom code block under each that one of them contains the code for Customer Update and the other one for OrderDtl:
The problem is that after setting them up, although I do not get any error at any level, only the Base Processing that is order earlier (10,20,30,…) takes effect.
In other words, when I give the priority to Customer update, Customer table updates but OrderDtl does not, and when OrderDtl’s Base processing is prioritized, Customer table does not get updated…
I even tried clipping the last part of each code where the ttResult table gets cleared and see face this issue.
Just to emphasize UBAQ runs with no problem:
And after running, I get this: