Skip to main content
Solved

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

  • 23 December 2022
  • 1 reply
  • 199 views

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 .

View original
Did this topic help you find an answer to your question?

1 reply

Yuriy Zaletskyy
Jr Varsity I
Forum|alt.badge.img+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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings