Event Handlers In Acumatica

 

Hello everybody,

today I want to share with you how order of event handlers in Acumatica is organized.

Each graph has list of event handlers for each type of manipultaion. Also new declarations of methods can be added to the start or then end of collection, and there are events which are added in the beginning of collection.

According to T300 event handlers which are added to the end of collection:

    • FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)

    • RowSelecting(PXCache sender, PXRowSelectingEventArgs e)

    • RowSelected(PXCache sender, PXRowSelectedEventArgs e)

    • RowInserted(PXCache sender, PXRowInsertedEventArgs e)

    • RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)

    • RowDeleted(PXCache sender, PXRowDeletedEventArgs e)

    • RowPersisted(PXCache sender, PXRowPersistedEventArgs e

Let's say we considered about RowPersisted event. Then the schema will be following:

Base.RowPersisted -> 1st level event handler -> 2nd level event handler. In other words, initially Acumatica code will be executed, and after your code will be executed.

There are also events which has another order which are added to the beginning of the collection:

• FieldSelecting(PXCache sender, PXFieldSelectingEventArgs e)

• FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)

• FieldUpdating(PXCache sender, PXFieldUpdatingEventArgs e)

• FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)

• RowInserting(PXCache sender, PXRowInsertingEventArgs e)

• RowUpdating(PXCache sender, PXRowUpdatingEventArgs e)

• RowDeleting(PXCache sender, PXRowDeletingEventArgs e)

• RowPersisting(PXCache sender, PXRowPersistingEventArgs e)

• CommandPreparing(PXCache sender, PXCommandPreparingEventArgs e)

• ExceptionHandling(PXCache sender, PXExceptionHandlingEventArgs e)

From RowPersisting prospective following chain will be executed:

2nd level.RowPersisting  -> 1st level.RowPersisting -> Base.RowPersisting. In other words initially your code will be executed, and only thereafter Acumatica code will be executed and (!!!!) modify your changes to some others. In my practice it was situation, that my changes to RowPersisting was lost because Acumatica basic code removed my code.

Probably you can have question, is there a way to modify this behaviour. What if I want to change order? Yes, it's possible. You just need to use PXAcumaticaEvent template. Look at code below:

protected void DAC_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e, PXRowUpdated del)
{
  //your code can be here 
  if (del != null)
     del(sender, e);
  //or here. Or even in both places
}
Or you can even ignore calling of base code.
protected void DAC_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e, PXRowUpdated del)
{
  //your code can be here 
}
In the second case basic code will not be executed.

With such tricks you can modify behavior in the way you like.

No Comments

Add a Comment
 

 

What Is Companyid In Acumatica

 

Hello everybody,

today I want to notice few words about companyid field. What is it's purpose. Initially Acumatica provides two !!!! companyid. 1 and 2. Why two? The first is for some Acumatica internal usage, and then your company will get id 2. Even if you believe that your company deserve to be 1, you'll get 2 or more. It means that first active company will have id 2 or bigger. So, if you have some DAC which should be used by few companies, then you just add companyid field, make it as key, and that's it, Acumatica will track to which company your entity should belong.

No Comments

 

Add a Comment
 

 

Grid Toolbar Buttons In Acumatica

 

Hello everybody,

have you ever wondered, that SkinID property may regulate grid toolbar set of buttons? For me it was unknown untill today. Here it is list of id's and buttons according to T200:

  • Primary: Adds the Add, Delete, Fit to Screen, and Exportbuttons to the toolbar. This value is typically used for a grid on a simple edit page that consists of the single grid.
  • Details or DetailsInTab: Adds the Refresh, Add, Delete, Fit to Screen, and Export buttons to the toolbar. This value is typically used for a grid that displays the detail data on a master-detail page
  • Inquire: Adds the Refresh, Fit to Screen, and Export buttons to the toolbar. This value is typically used for grids on inquiry and processing pages
  • Selector: Adds the Refresh and Fit to Screen buttons to the toolbar
  • Attributes or ShortList: Hides the toolbar.

Now I know how to configure buttons of grid

No Comments

 

Add a Comment
 

 

Merged And Read Only Modes In Acumatica

 

Hello everybody,

today another notice. Acumatica can provide values in two modes: merged and read-only.

So, what is merged? Imagine that user worked about the form, and made some changes at grid. Will changes apper in DB? Untill will be executed Persist, not. Data will be only in cache. Some time it is useful to compare data in cache with data in db. In order to get merged data you can use PXSelectReadOnly type or PXSelectGroupBy. For merged results you can use PXSelect or PXSelectJoin.

No Comments

 

Add a Comment
 

 

Enabling Reusable Grid Filters

 

Hello everybody,

today I want to note reusable grid filters. Acumatica has interesting dialog window, wich is named Filter Settings in which user can define and save custom fitlers and then use them every time this user opens the page. They are recommended for usage at inquiry and processing pages, so users can customize these pages to show specific data that is most relevant to their needes and responsibilities. If you wonder how to convert ordinary view to filterable view here is the way: PXFilterable attribute.

[PXFilterable]
public PXSelectReadonly<AnticipatedPayrollDetail> AnticipatedPayrollDetails;

I applied it to my page, and here is example of what I got:

So, in case if you need to add filtering option to your screen, attribute PXFilterable is your friend.

No Comments

Add a Comment
 

 

Order Of Views In Graph In Acumatica

 

Hello everybody,

note of today is value of orders. In the word of C# if you work with your class, you as usually don't care what you declare in your code. But in Acumatica graph order of data viewes is important, because they define order of saving data to the database. If you think that surprises are completed then here it is another one: order of viewes doesn't define order of data viewes execution. And the third one, view that is binded to PrimaryView should be defined first in the graph. 

No Comments

 

Add a Comment
 

 

Execute Update Delete Insert In Acumatica

 

Welcome readers of my blog.

Have you ever wondered, what Acumatica will execute first: ExecuteDelete, ExecuteUpdate or ExecuteInsert? Today I revealed for myself following order:

1. ExecuteUpdate

2. ExecuteInsert

3. ExecuteDelete.

No Comments

 

Add a Comment
 

 

Redirection Types In Acumatica

 

Hello everybody,

today I want to notice what kind of redirections are available in Acumatica:

  • PXRedirectRequiredException opens the specified application page in the same window or a new one. By default, the user is redirected in the same window.
  • PXPopupRedirectException opens the specified application page in a pop-up window.
  • PXReportRequiredException opens the specified report in the same window or a new one. By default, the report opens in the same window.
  • PXRedirectWithReportException opens two pages: the specified report in a new window, and the specified application page in the same window.
  • PXRedirectToUrlExceptionopens the webpage with the specified external URL in a new window.  This exception is also used for opening an inquiry page that is loaded into the same window by default.

No Comments

 

Add a Comment
 

 

Rowdefaulting And Copy Paste In Acumatica Or Copy Paste Mode In Acumatica

 

Hello everybody,

recently I had the following situation. 

According to business logic, I created RowDefaulting. And it worked great. Then business analyst decided to check copy/paste functionality of Acumatica, and you know what? He discovered that copy/paste is broken. After investigation I discovered that it was due to RowDefaulting event.  For me it meant the following, I need to turn off RowDefaulting after copy/paste. 

After usage of reflector, I noticed interesting property  IsCopyPasteContext in the graph. 

So I modified function RowDefaulting.

private void RowDefaulting(PXGraph graph)

{

      if( !graph.IsCopyPasteContext )

          {

                    //do some row defaulting logic.

          }

}

 

Hope you enjoyed this tip

 

An Object Reference Is Required For The Non Static Field Method Or Property Px Data Pxselectbase Acumatica Dac Select In Acumatica

 

Hello everybody,

today I want to share how to fight with error like 

Error 22 An object reference is required for the non-static field, method, or property 'PX.Data.PXSelectBase<Acumatica DAC>.Select(params object[])' bla bla bla

As usually it means that you try to use this in selector of Extension class. Just replace this at Base or Base2 and your problem will go away.

for example 

CR.Location customerLoc = PXSelect<CR.Location, Where<CR.Location.bAccountID, Equal<Required<CR.Location.bAccountID>>, 

                            And<CR.Location.locationID, Equal<Required<CR.Location.locationID>>>>>.Select(this, customer.BAccountID, customer.DefLocationID);

should be 

CR.Location customerLoc = PXSelect<CR.Location, Where<CR.Location.bAccountID, Equal<Required<CR.Location.bAccountID>>, 

                            And<CR.Location.locationID, Equal<Required<CR.Location.locationID>>>>>.Select(Base, customer.BAccountID, customer.DefLocationID);

and your code will be compiled again