0
votes

I am trying to update the price of an SOLine and following through debug it seems to be correct, but the updated price never gets to the table. What am I missing in the code below:

SOOrderEntry soOrderEntry = PXGraph.CreateInstance<SOOrderEntry>();
//
//Added this line per Joshua's recommendation
soOrderEntry.Document.Current = soOrder;
//
bool orderUpdated = false;
foreach (EDImportExcept except in excepts)
{
    if (except.ExceptReason == "P" && soOrder != null)
    {
         SOLine soLine = PXSelect<SOLine, 
             Where<SOLine.orderNbr, Equal<Required<SOLine.orderNbr>>,
                 And<SOLineExt.usrEDILineNbr,
                   Equal<Required<SOLineExt.usrEDILineNbr>>>>>
             .Select(this, soOrder.OrderNbr, except.ItemLineNbr);
         soLine.UnitPrice = except.EDIUnitPrice;
         soOrderEntry.Transactions.Current = soLine;
         soOrderEntry.Transactions.Update(soLine);
         orderUpdated = true;
    }
    except.ExceptResolution = "A";
    except.Active = false;
    exceptMaint.Exception.Update(except);
    exceptMaint.Actions.PressSave();
}
if (orderUpdated)
    soOrderEntry.Actions.PressSave();
1
You do not appear to set the .Current of the Document view [Header] in the SOOrderEntry graph before you attempt to update child records. - Joshua Van Hoesen
I added an assignment to assign the soOrder object to Document.Current, but the update still does not commit properly. - Jerry Welliver
Try to invoke soOrderEntry.Actions.PressSave(); in the loop - Samvel Petrosov

1 Answers

0
votes

I finally found the problem with this and I wanted to share it with the community. As a shot in the dark, I opened SO301000 to see if there was any logic blocking the change and discovered that the field displayed in the column labeled Unit Price in the grid is actually CuryUnitPrice not UnitPrice. I changed my code to update CuryUnitPrice and it worked like a charm. Lesson learned - check the form to verify which field it is if code does not appear to work.