What is the difference between Press() & PressButton() ?
Solved
What is the difference between Press() & PressButton() ?
Best answer by Yuriy Zaletskyy
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
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.