Here is my use-case:
a user changes a drop-down value (UsrShipStatus)
I need that value to update another field (UsrDfltWarehouse), this field will then create a dialogue box where I need to select “OK”
This then calls the function private void setWarehouses(POOrder row).
Below is the code in use here, I’m just lost on how to even interact with a dialogue box, or if I even need to (see comments below).
public class POOrderEntry_Extension:PXGraphExtension<POOrderEntry>
{
protected void POOrder_UsrShipStatus_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
{
if (InvokeBaseHandler != null)
InvokeBaseHandler(cache, e);
var row = (POOrder)e.Row;
if (row == null) return;
POOrderExt pOOrderExt = cache.GetExtension<POOrderExt>((object)row);
if (pOOrderExt.UsrShipStatus == "POE")
{
const string CUSTOMER_TYPE = "C";
/* PORT LB - Port Long Beach */
const int PORT_LB_PROD = 443;
row.ShipToBAccountID = PORT_LB_PROD;
row.ShipDestType = CUSTOMER_TYPE
row.UsrDfltWarehouse = “DIRECT”
// ^^THIS IS THE CODE THAT WILL EXECUTE THE DIALOGUE BOX BELOW, maybe I should just call SetWarehouses(row) here to bypass the dialogue check below?
}
}
protected void POOrder_UsrDfltWarehouse_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{
string msg = "Apply warehouse change to all Order Lines?";
var row = (POOrder)e.Row;
WebDialogResult result = Base.Transactions.Ask("Information", msg, MessageButtons.OKCancel);
if (result == WebDialogResult.OK)
{
setWarehouses(row);
}
}
//This set of code applies the warehouse to all the PO Lines based on the warehouse value in the UsrDfltWarehouse field
private void setWarehouses(POOrder row)
{
POOrderExt PoExt = PXCache<POOrder>.GetExtension<POOrderExt>(row);
var site = PoExt.UsrDfltWarehouse;
foreach (POLine line in Base.Transactions.Select())
{
line.SiteID = site;
Base.Transactions.Update(line);
Base.Transactions.View.RequestRefresh();
}
}
I know this is a bit of a read, but I’ve never worked with dialogue box answers in the code editor. I know how it’s done on import scenarios, but not here. Any help or links would be greatly appreciated.
THANK YOU EVERYONE!