To Add Additional Information to Push Notifications
In MYOB Acumatica or an MYOB Acumatica Framework-based application, you can add additional information to push notifications, such as the username of the user that performed the data change or the business date when the data transaction is performed. The additional information can be added to the AdditionalInfo element of notifications in JSON format. For more information on the format of notifications, see Push Notification Format.
The dictionary of additional information can be implemented in a project of your MYOB Acumatica extension library. To add additional information to push notifications, follow the instructions in this topic.
To Add Additional Information to Push Notifications
- In a project of your MYOB Acumatica extension library, define a class that implements the PX.Data.PushNotifications.ICommitEventEnricher interface.
- In the class that implements the ICommitEventEnricher interface,
implement the Enrich() method of the interface. In the method, add the
properties that you want to be returned in push notifications.Note: The Enrich() method is called in the PX.Data.PXTransactionScope.Dispose() method. Therefore, the Enrich() method must not return data that is not accessible in this scope.
The following code shows a sample implementation of the ICommitEventEnricher interface, which adds the business date and the name of the user to the AdditionalInfo element of notifications in JSON format.
using PX.Data; using PX.Data.PushNotifications; public class CommitEventEnricher : ICommitEventEnricher { public void Enrich(IQueueEvent commitEvent) { var businessDate = PXContext.PXIdentity?.BusinessDate; var userName = PXContext.PXIdentity?.IdentityName; commitEvent.AdditionalInfo.Add(nameof(businessDate), businessDate); commitEvent.AdditionalInfo.Add(nameof(userName), userName); } }
- Build the project of your MYOB Acumatica extension library.
- Run MYOB Acumatica and make sure that when the results of the query change, the application includes the
additional information in the AdditionalInfo element of the
notifications in JSON format, as shown in the following notification example.
{ ... "TimeStamp":636295833829493672, "AdditionalInfo": { "businessDate":"2017-05-05T15:16:23.1", "userName":"admin" } }