Skip to main content
Question

Any unsaved changes will be discarded in Modern UI

  • February 5, 2026
  • 5 replies
  • 74 views

Forum|alt.badge.img

Hi all,

I am experiencing an issue with the Modern UI.

 

When I click the ADD & CLOSE button, I receive the following message on the screen.

How can I resolve this?

Here is the relevant HTML/TypeScript code for reference:
 

export class BZLines extends PXView {
@columnConfig({ allowSort: false, width: 60, allowCheckAll: true }) Selected: PXFieldState;
InventoryID: PXFieldState<PXFieldOptions.Disabled>;
SiteID: PXFieldState<PXFieldOptions.Disabled>;
InventoryID_description: PXFieldState<PXFieldOptions.Disabled>;
OpenQty: PXFieldState<PXFieldOptions.Disabled>;
Quantity: PXFieldState;
}


<qp-panel id="BZLines" caption="Items Selection">
<qp-grid id="grid-BZLines" view.bind="BZLines"></qp-grid>
<footer>
<qp-button id="CstButton85" caption="ADD & CLOSE" dialog-result="OK"></qp-button>
<qp-button id="CstButton86" caption="CANCEL" dialog-result="Cancel"></qp-button>
</footer>
</qp-panel>

 

Thank you for your help.

5 replies

zherring
Freshman II
Forum|alt.badge.img
  • Freshman II
  • February 5, 2026

I have not dived into the modern UI too much yet but you might need to provide more context on this one for others. Make sure you click save on the screen before going into the “Items Selection” panel and clicking “Add & Close”.


Forum|alt.badge.img
  • Author
  • Freshman II
  • February 5, 2026

@zherring, document has been saved.


Forum|alt.badge.img+9
  • Captain II
  • February 5, 2026

@VaheGhazaryan 

 

Can you share your C# code?


Forum|alt.badge.img
  • Author
  • Freshman II
  • February 9, 2026

Hi ​@aiwan,

public PXAction<SOOrder> BZSellItems;
[PXUIField(DisplayName = BZActionNames.ConsSellItems, MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Visible = true)]
[PXButton(CommitChanges = true, Category = "Consignment")]
public IEnumerable bzSellItems(PXAdapter adapter)
{
if (this.Base.Document.Current != null && this.BZLines.Select().Count > 0)
{
if (this.BZLines.AskExt(true) == WebDialogResult.OK)
bzSellItems2();
}

return adapter.Get();
}

protected void bzSellItems2()
{
if (this.Base.Document.Current != null)
{
List<BZSellReturnItems> linesForSell = GetLinesForReturnOrSell();
if (linesForSell.Count == 0)
return;

bool redirectToGeneratedOrder = false;
int? saveCustId = this.Base.Document.Current.CustomerID;
SOOrderEntry graph = PXGraph.CreateInstance<SOOrderEntry>();
BZSOSetupExt setupExt = PXCache<SOSetup>.GetExtension<BZSOSetupExt>(Base.sosetup.Current);
SOOrder order = null;
if (setupExt != null)
{
order = new SOOrder
{
OrderType = setupExt.UsrBZInvoiceOrderType,
Status = SOOrderStatus.Open
};
graph.Document.Current = graph.Document.Insert(order);
graph.Document.Cache.SetValueExt<SOOrder.customerID>(graph.Document.Current, saveCustId);
graph.Document.Cache.SetValue<BZSOOrderExt.usrBZOrigRefNbr>(graph.Document.Current, this.Base.Document.Current.OrderNbr);
graph.Document.Update(order);

foreach (BZSellReturnItems sellLine in linesForSell)
{
if (sellLine.Selected == true)
{
SOLine line = PXCache<SOLine>.CreateCopy(ConvertToSOLineForSell(sellLine));
line.OrderType = null;
line.OrderNbr = null;
line.LineNbr = null;
line.ManualPrice = true;
line = graph.Transactions.Insert(line);
redirectToGeneratedOrder = true;
}
}
}

graph.Actions.PressSave();

if (graph.Accessinfo.ScreenID == "IN.30.50.00")
{
if (order != null)
{
graph.prepareInvoice.Press();
}
}
else
{
if (redirectToGeneratedOrder)
throw new PXRedirectRequiredException(graph, null);
}
}
}

 


jhonlloydgelica69
Freshman II

hello ​@VaheGhazaryan I think the leave site warning appears because the grid cache has uncommited changes (selected checkboxes) try to call BZLines.Cache.Clear(); in you action button which removes the dirty state and prevents the browser warning.

 

public PXAction<SOOrder> BZSellItems;

[PXUIField(DisplayName = BZActionNames.ConsSellItems, MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select, Visible = true)]

[PXButton(CommitChanges = true, Category = "Consignment")]

public IEnumerable bzSellItems(PXAdapter adapter)

{

if (this.Base.Document.Current != null && this.BZLines.Select().Count > 0)

{

if (this.BZLines.AskExt(true) == WebDialogResult.OK)

bzSellItems2();

}
BZLines.Cache.Clear();

return adapter.Get();

}