Solved

What is the difference between Press() & PressButton() ?

  • 23 December 2022
  • 1 reply
  • 112 views

What is the difference between Press() & PressButton() ?

icon

Best answer by Yuriy Zaletskyy 22 January 2023, 09:30

View original

1 reply

Userlevel 5
Badge +3

Press is used mainly for what you see, is what you get.

PressButton allows you to modify adapter, and as outcome add more logic, before button Action will be executed.

Example below allows to execute action in the context of mass execution, instead of single one:

private static bool TryCreateDeposit(CCBatchMaint graph)
{
try
{
var adapter = new PXAdapter(graph.BatchView)
{
MassProcess = true
};
graph.createDeposit.PressButton(adapter);

example below: 

Actions[_processButtonName].PressButton();

has no difference from ordinary Press.

Besides that, exists also PressButtonIfEnabled ( you may find it useful ):

		protected virtual void PressButtonIfEnabled(PXAction action, bool suppressRedirectExc)
{
try
{
if (action.GetEnabled())
{
action.Press();
}
else
{
PXButtonState bs = action.GetState((object)null) as PXButtonState;
throw new PXActionDisabledException(bs?.DisplayName ?? bs?.Name);
}
}
catch (PXBaseRedirectException) when (suppressRedirectExc)
{
// it is a temporary fix waiting for AC-187429
}
}

Below goes imitation of notification click, which requires additional arguments, which ordinary Press will not provide as well:

PXAdapter adapterSO = new PXAdapter(soOrderEntryGraph.CurrentDocument);

if (filter.EmailSalesOrder == true)
{
var args = new Dictionary<string, object>();
args["notificationCD"] = "SALES ORDER";

adapterSO.Arguments = args;

soOrderEntryGraph.notification.PressButton(adapterSO);
}

to sum up: Press is simplified edition of PressButton .

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved