Even with a manually unapproved PO, when I try to update the InternalComments_c on the uBAQ, I get the error, “The PO has been approved. Changes not allowed”.
This leads me to believe that the DefaultCode has an issue (because my initial condition checks to see if the PO is approved and if not, it goes to the default code):
// <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", "PO"))
{
var resultQuery = queryResultDataset.Results
.Where(row => !string.IsNullOrEmpty(row.RowMod) && row.RowMod != "P");
foreach (var ttResult in resultQuery)
{
var ds = new Erp.Tablesets.UpdExtPOTableset();
// Query to object mapping
{
var PODetail = new Erp.Tablesets.PODetailRow
{
ClassID = ttResult.PODetail_ClassID,
Company = ttResult.PODetail_Company,
LineDesc = ttResult.PODetail_LineDesc,
OpenLine = ttResult.PODetail_OpenLine,
PartNum = ttResult.PODetail_PartNum,
POLine = ttResult.PODetail_POLine,
PONUM = ttResult.PODetail_PONUM,
UnitCost = ttResult.PODetail_UnitCost,
};
PODetail.SetUDField<System.String>("InternalCommentsLine_c", ttResult.PODetail_InternalCommentsLine_c);
ds.PODetail.Add(PODetail);
var POHeader = new Erp.Tablesets.POHeaderRow
{
ApprovalStatus = ttResult.POHeader_ApprovalStatus,
Approve = ttResult.POHeader_Approve,
AutoPrintReady = ttResult.POHeader_AutoPrintReady,
Company = ttResult.POHeader_Company,
Confirmed = ttResult.POHeader_Confirmed,
OpenOrder = ttResult.POHeader_OpenOrder,
OrderDate = ttResult.POHeader_OrderDate,
PONum = ttResult.POHeader_PONum,
PromiseDate = ttResult.POHeader_PromiseDate,
};
ds.POHeader.Add(POHeader);
var PORel = new Erp.Tablesets.PORelRow
{
BaseQty = ttResult.PORel_BaseQty,
Company = ttResult.PORel_Company,
Plant = ttResult.PORel_Plant,
POLine = ttResult.PORel_POLine,
PONum = ttResult.PORel_PONum,
PORelNum = ttResult.PORel_PORelNum,
};
ds.PORel.Add(PORel);
}
BOUpdErrorTableset boUpdateErrors = updater.Update(ref ds);
if (this.BpmDataFormIsPublished()) return;
ttResult.RowMod = "P";
// Object to query mapping
{
var PODetail = ds.PODetail.FirstOrDefault(
tableRow => tableRow.Company == ttResult.PODetail_Company
&& tableRow.POLine == ttResult.PODetail_POLine
&& tableRow.PONUM == ttResult.PODetail_PONUM);
if (PODetail == null)
{
PODetail = ds.PODetail.LastOrDefault();
}
var POHeader = ds.POHeader.FirstOrDefault(
tableRow => tableRow.Company == ttResult.POHeader_Company
&& tableRow.PONum == ttResult.POHeader_PONum);
if (POHeader == null)
{
POHeader = ds.POHeader.LastOrDefault();
}
var PORel = ds.PORel.FirstOrDefault(
tableRow => tableRow.Company == ttResult.PORel_Company
&& tableRow.POLine == ttResult.PORel_POLine
&& tableRow.PONum == ttResult.PORel_PONum
&& tableRow.PORelNum == ttResult.PORel_PORelNum);
if (PORel == null)
{
PORel = ds.PORel.LastOrDefault();
}
if (PODetail != null)
{
ttResult.PODetail_ClassID = PODetail.ClassID;
ttResult.PODetail_Company = PODetail.Company;
ttResult.PODetail_InternalCommentsLine_c = PODetail.UDField<System.String>("InternalCommentsLine_c", throwIfNull:false);
ttResult.PODetail_LineDesc = PODetail.LineDesc;
ttResult.PODetail_OpenLine = PODetail.OpenLine;
ttResult.PODetail_PartNum = PODetail.PartNum;
ttResult.PODetail_POLine = PODetail.POLine;
ttResult.PODetail_PONUM = PODetail.PONUM;
ttResult.PODetail_UnitCost = PODetail.UnitCost;
}
if (POHeader != null)
{
ttResult.POHeader_ApprovalStatus = POHeader.ApprovalStatus;
ttResult.POHeader_Approve = POHeader.Approve;
ttResult.POHeader_AutoPrintReady = POHeader.AutoPrintReady;
ttResult.POHeader_Company = POHeader.Company;
ttResult.POHeader_Confirmed = POHeader.Confirmed;
ttResult.POHeader_OpenOrder = POHeader.OpenOrder;
ttResult.POHeader_OrderDate = POHeader.OrderDate;
ttResult.POHeader_PONum = POHeader.PONum;
ttResult.POHeader_PromiseDate = POHeader.PromiseDate;
}
if (PORel != null)
{
ttResult.PORel_BaseQty = PORel.BaseQty;
ttResult.PORel_Company = PORel.Company;
ttResult.PORel_Plant = PORel.Plant;
ttResult.PORel_POLine = PORel.POLine;
ttResult.PORel_PONum = PORel.PONum;
ttResult.PORel_PORelNum = PORel.PORelNum;
}
}
if (boUpdateErrors?.BOUpdError?.Count > 0)
{
queryResultDataset.Errors
.AddRange(
boUpdateErrors.BOUpdError
.Select(
e => new ErrorsUbaqRow
{
TableName = e.TableName,
ErrorRowIdent = ttResult.RowIdent,
ErrorText = e.ErrorText,
ErrorType = e.ErrorType
}));
}
}
}
var resultsForDelete = queryResultDataset.Results
.Where(row => row.RowMod != "P")
.ToArray();
foreach (var ttResult in resultsForDelete)
{
queryResultDataset.Results.Remove(ttResult);
}
foreach (var ttResult in queryResultDataset.Results)
{
ttResult.RowMod = "";
}