Skip to main content

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

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: 

Actionss_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>();
argss"notificationCD"] = "SALES ORDER";

adapterSO.Arguments = args;

soOrderEntryGraph.notification.PressButton(adapterSO);
}

to sum up: Press is simplified edition of PressButton .


Reply