Few notes about PXAccumulatorAttribute
- If to inherit from PXAccumulatorAttribute, you'll have access to member _SingleRecord. If to set in constructor to true, you'll configure single record update mode.
- There is PrepareInsert method. This method intended for updating policy for the data fields.
- PrepareInsert is invoked within Persist method, before Acumatica framework generates SQL commands for inserted data records.
- Among paramethers of PrepareInsert method there is PXAccumulatorCollection, which has method Update. In this method it's possible to configure fields which will be updated during PrepareInsert
- Method Update has following policies: PXDataFieldAssign.AssignBehavior.Initialize ( new value is inserted into the database column only if value is null ), PXDataFieldAssign.AssignBehavior.Replace ( new value replces old value ), PXDataFieldAssign.AssignBehavior.Summarize ( new value is added to the value stored in the database ), PXDataFieldAssign.AssignBehavior.Maximize ( maximum of the new value and the value from the database is saved in the database ), PXDataFieldAssign.AssignBehavior.Minimize ( minimum of the new value and the value form database is saved in the database )
So, in order to implement Accumulator attribute, following steps are needed:
1. Inherit class from PXAccumulatorAttribute
2. Implement PrepareInsert method
3. Implement PersistInserted method.