Records Post-Processing

Hi All, Today want to share with you some thoughts about how to organize additional processing in Acumatica.Commonly we may need to to something together with document release: create contract, send EDI request (like inter-company), call 3rd party API and so on. Most common way to do so is just code infection in the save or release process. Than you do 2 things just together.However this leads to some troubles: Performance – when you do 2 operations simultaneously you have to lock transaction for longer period of time, that finally affects other users as they have to wait. Repeating – if operation fails and you have to repeat it you… Read more

Select Multiple Documents into One Grid

Hi Everyone, In some situations you may want to show different unconnected documents inside one grid. Just for example you want to create Customer Overview screen and show all Invoices, Payments and Sales Orders together in one place. Join tables together is not the best approach, as you will have to add different columns with same names for fields from different tables. Better Approach is select them independently in Data View delegate and merge them into one virtual DAC. So plan is the following: Create a new Virtual DAC that will represent any document in the system. Please note that this DAC should have a Key that should unique even… Read more

Totals Calculation for Inquiry

Hi Everyone, Today want to give you an idea of better architecture for inquiry with some aggregated calculations. Problem Statenment Let assume that you have an inquiry when you need to calculate totals together on the filter together with printing details like described here: Than how can you do that? One of the obvious way may be to create a dataview and iterate thought ever record to calculate total: public PXFilter<InquiryFilter> Filter; public PXSelect<Batch> Records; public IEnumerable records() { decimal docsTotal = 0m; foreach(Batch row in Records.Select()) { docsTotal += res.ControlTotal; yield return row; } //… } However it is not really good idea to iterate thought all records if you need to get a total of records selected, as you have to ignore paging… Read more

Context Parameters

Hi Everyone, In this topic I want to cover another architecture pattern we have in Acumatica – Usage of context related parameters. Problem Statement Within the event model it is not easy to pass parameters into the other child or related events. There is a way with local variables how it is shown in T300 Training Guide and Override Release Action Lesson. However it is a really not nice approach if events happens in different objects like here: public class SomeGraph : PXGraph<SomeGraph> { public void CreateBatch() { bool needValidate = true; //Create Batch } } public class JournalEntry : PXGraph<JournalEntry> { public void DAC_RowUpdated(PXCache cache, PXRowUpdatedEventArgs) { if (needValidate) { … } } } Solution In Acumatica we use an approach that we call Scopes. Scope is a class that set… Read more

Using PXView in DataView Delegate

Hi Everyone, Today I want to share with you one way how you can keep your code simpler. Lets assume you have some big data view declaration – PXSelect<Table, <InnerJoin, …. <AnotherJoin, … <MoreJoins, …. <Where<, …. <MoreWheres< …. SomeDataView And something like this for 10-20-30 lines of code. I’m pretty sure that you can understand what do i mean. And also this select declaration may be inside Acumatica base code and you want to customize it. Your task is to create a new data view delegate and select the same data with some additional filtering or dynamic calculations. But we cannot just create delegate and call dataview data, as… Read more