Suppose that you need to configure Acumatica ERP to send push notifications for a query that is defined as a class in the source code of the application—that is, for a built-in definition of the query.
In a project of your Acumatica ERP extension library, you will define a class that implements the PX.PushNotifications.Sources.IInCodeNotificationDefinition interface. You will then build the project of your Acumatica ERP extension library and test the built-in query definition.
Before you begin performing the steps of this activity, do the following:
You can find the final code of this activity in the TestInCodeDefinition.cs file in the Help-and-Training-Examples repository on GitHub.
To create a built-in query definition, do the following:
using PX.PushNotifications.Sources; public class TestInCodeDefinition : IInCodeNotificationDefinition { }
using PX.Data; using PX.PushNotifications.UI.DAC; using System; using PX.Data.BQL.Fluent; using PX.PushNotifications.Sources; public class TestInCodeDefinition : IInCodeNotificationDefinition { public Tuple<BqlCommand, PXDataValue[]> GetSourceSelect() { return Tuple.Create( SelectFrom<PushNotificationsHook>. LeftJoin<PushNotificationsSource>. On<PushNotificationsHook.hookId. IsEqual<PushNotificationsSource.hookId>>.View .GetCommand(), new PXDataValue[0]); } }
null
using PX.Data; using PX.PushNotifications.UI.DAC; using System; using PX.Data.BQL.Fluent; using PX.PushNotifications.Sources; public class TestInCodeDefinition : IInCodeNotificationDefinition { ...
public Type[] GetRestrictedFields() { return new[] { typeof(PushNotificationsHook.address), typeof(PushNotificationsHook.type), typeof(PushNotificationsSource.designID), typeof(PushNotificationsSource.inCodeClass), typeof(PushNotificationsSource.lineNbr) }; } }
On the Built-In Definitions tab of the Push Notifications (SM302000) form, create a push notification definition and make sure that you can select the new built-in query definition by its class name in the Class Name column. The class of the built-in query definition, which implements the IInCodeNotificationDefinition interface, is detected by the system and automatically added to the list of classes available for selection on the tab.
After you have defined a push notification definition that uses a built-in query definition on the Push Notifications form, you can obtain the results of the data query defined with a built-in query definition by using the following endpoint: http(s)://<Acumatica ERP instance URL>/PushNotifications/<full class name of the built-in query definition>. For example, suppose that you want to retrieve the results of the data query defined with the PX.PushNotifications.Sources.TestInCodeDefinition class from a local Acumatica ERP instance with the name AcumaticaDB. You should use the following URL to obtain the data: http(s)://localhost/AcumaticaDB/PushNotifications/PX.PushNotifications.Sources.TestInCodeDefinition. The endpoint returns the data in JSON format.