different reaction between with UI and REST API

34 views Asked by At

I would like to update the description field with the order number. It's ok when I use the ui acumatica, but the field is empty when I use the rest webservice.

Endpoint : Salesorder?

protected void SOOrder_RowPersisted(PXCache cache, PXRowPersistedEventArgs e)
{
  
  var row = (SOOrder)e.Row;
  if (row==null) return;
  BAccount un_client=PXSelect<BAccount , Where<BAccount.bAccountID, Equal<Required<BAccount.bAccountID>>>>.Select(this.Base,row.CustomerID);
  if (un_client!=null)
  {
    row.OrderDesc=Mid(Convert.ToString(row.OrderNbr)+" (" +Convert.ToString(row.CustomerOrderNbr)+") "+Convert.ToString(un_client.AcctName),0,250);
  }     
}

Update 2024-03-02 When I use the SOOrder_RowPersisting

protected void SOOrder_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
{
  
  var row = (SOOrder)e.Row;
  if (row==null) return;
  BAccount un_client=PXSelect<BAccount , Where<BAccount.bAccountID, Equal<Required<BAccount.bAccountID>>>>.Select(this.Base,row.CustomerID);
  if (un_client!=null)
  {
    row.OrderDesc=Mid(Convert.ToString(row.OrderNbr)+" (" +Convert.ToString(row.CustomerOrderNbr)+") "+Convert.ToString(un_client.AcctName),0,250);
  }         
}

I have not the good OrderNbr, because I have not save enter image description here

And, when I save the new is not update enter image description here

1

There are 1 answers

2
Zoltan Febert On

You need to use RowPersisting instead of RowPersisted, and you also need to send some real data update with your request. It's OK if you send some placeholder data in the Description.

{
    "OrderType": {
        "value": "SO"
    },
    "OrderNbr": {
        "value": "SO006777"
    },
    "Description": {
        "value": "it will be updated when persisting the row"
    }
}