Skip to main content
Solved

What is the purpose of the PXAdapter parameter for Actions functions?


deybanperez83
Jr Varsity III

When you create a new Action in Acumatica you have two ways of doing it:

1) Using PXAdapter

public virtual IEnumerable migrateSalesPeopleFromAcumatica(PXAdapter adapter)
{
  ///Any Code
  return adapter.Get();
}

2) Without PXAdapter as parameter

public virtual void migrateSalesPeopleFromAcumatica()
{
   ///Any Code
}

 

So my questions are:

1)  What is the purpose of the PXAdapter parameter?

2) When should I use one option over the other one?

 

Regards

Best answer by Dmitrii Naumov

PXAdapter contains some additionalinfo about the invoked action and state of the screen. 

E.g. PXAdapter contains Searches that allow you to identify what records the action has been triggered on. 

Also, return from an action with PXAdapter contains info on what to display after the action completion. 

 

Action without PXAdapter is kind of independent from the context it has been invoked from. Well, you can still access the graph and Currents of the caches, but Currents of the caches is something that you cannot really rely on. 

 

So, my recommendation would be to use action with PXAdapter when you need to process some record/list of records. And if your action just does something that does not need to know what record it was invoked on you can use Action without PXAdapter.

 

Remember that actions can be invoked from different contexts. E.g. if you have ‘Release’ action on some form, that same action can also be invoked from a GI that is mapped from that screen. Or from API. Or from a processing form that uses that actions from Automation. So, the cache Current is really not something that is reliable, as in different situations it may be set or may not be set. And some actions may be triggered on set of records instead of just one record that you’d expect when you just use an action from a screen.

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

6 replies

Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • 632 replies
  • Answer
  • April 7, 2022

PXAdapter contains some additionalinfo about the invoked action and state of the screen. 

E.g. PXAdapter contains Searches that allow you to identify what records the action has been triggered on. 

Also, return from an action with PXAdapter contains info on what to display after the action completion. 

 

Action without PXAdapter is kind of independent from the context it has been invoked from. Well, you can still access the graph and Currents of the caches, but Currents of the caches is something that you cannot really rely on. 

 

So, my recommendation would be to use action with PXAdapter when you need to process some record/list of records. And if your action just does something that does not need to know what record it was invoked on you can use Action without PXAdapter.

 

Remember that actions can be invoked from different contexts. E.g. if you have ‘Release’ action on some form, that same action can also be invoked from a GI that is mapped from that screen. Or from API. Or from a processing form that uses that actions from Automation. So, the cache Current is really not something that is reliable, as in different situations it may be set or may not be set. And some actions may be triggered on set of records instead of just one record that you’d expect when you just use an action from a screen.


deybanperez83
Jr Varsity III
  • Author
  • Jr Varsity III
  • 13 replies
  • April 8, 2022

Awesome @Dmitrii Naumov thank you very much!


  • Freshman I
  • 2 replies
  • November 9, 2022

Hi @Dmitrii Naumov . Can you provide an example for how to use PXAdapter to retrieve the corresponding cache Current?


Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • 632 replies
  • November 9, 2022

@colinsim

I don't think it is something that should be done. 

You can have two different types of actions:

  1. Action that affects the current record on the screen, it can work with Current of the cache.
  2. Action that is not necessary working with the currently displayed record, e.g. any action that can also be be triggered from a processing screen for multiple records at the same time. 

So you either use Current of the cache or PXAdapter to get record(s). 

These two should not be mixed together.


  • Freshman I
  • 2 replies
  • November 9, 2022

Thanks for your quick response @Dmitrii Naumov .

I understand and agree with what you said. Just curious if you have examples of how to use PXAdapter as its API is rather cumbersome and annoying to use (though it could be that I don’t fully understand how it should be used).


Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • 632 replies
  • November 9, 2022

@colinsim an example of how to use PXAdapter to get records to process can be found for instance in SOOrderEntry graph:

List<SOOrder> list = adapter.Get<SOOrder>().ToList()

So, it should be pretty straight forward. 

As I mentioned before, if you work with PXAdapter, you can expect that there may be multiple records sent to be processed, hence the List instead of a single record. 


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