Here is a way you can update the Unit Price.
This is the ##BASE## directive after you save the UBAQ with the fields you wish to update.
1 - Set ttResults.POHeader_Approve = false
2 - Set ttResults.POHeader_ReadyToPrint = false
3 - Set ttResults.POHeader.ApprovalStatus = “U”
Changed Row for 1 - 3
4 - Fill Table By Query (create TableSet variable based on POTableSet)
4a - Source will be ttResults
4b - Mapping will be all custom fields that the standard UBAQ logic (#5) does not handle
4c - This table will be used quite a bit
5 - Standard UBAQ code (no changes)
6 - Call PO.GetByID to new variable ds (PO) using ttResultsRow. (PONUM)
7 - Set PO.POHeader.Approve = false (changed row)
8 - Custom Code
// SaveResults = POTableSet from #4
// PO = ds from #6
// Just sample for UnitCost
var ResultRows = SavedResults.PODetail.Where(sr => sr.RowMod == "U");
foreach(var ResultRow in ResultRows)
{
int PONum = ResultRow.PONUM;
int POLine = ResultRow.POLine;
decimal Cost = ResultRow.DocUnitCost;
var PORows = PO.PODetail.Where(po => po.Company == Session.CompanyID && po.PONUM == PONum && po.POLine == POLine);
foreach(var PORow in PORows)
{
PORow.RowMod = "U";
PORow.ScrUnitCost = Cost;
}
}
9 - PO.ChangeUnitPrice using var:PO
10 - PO.Update BO referencing var:PO
11 - Set ApprovalStatus to “A”
12 - Set ReadyToPrint = true
13 - Set Approve = true
For 11 - 13 All rows
14 - Custom Code to Set RowMod = U in PO.POHeader
15 - Run PO.Update using PO ds
16 - Not really need but custom code that takes the PO variable and then update ttResults to get the screen to show all the update values. Can be done client side in Dashboard code as well on refresh.
var ResultRows = SavedResults.PODetail.Where(sr => sr.RowMod == "U");
foreach(var ResultRow in ResultRows)
{
int PONum = ResultRow.PONUM;
int POLine = ResultRow.POLine;
decimal Cost = ResultRow.DocUnitCost;
var Result = ttResults.Where(t => t.PODetail_PONUM == PONum && t.PODetail_POLine == POLine);
foreach (var Row in Result)
{
Row.PODetail_DocUnitCost = Cost;
}
}