To Create a Built-In Definition

In MYOB Acumatica or an MYOB Acumatica Framework-based application, you can configure 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. The built-in definition can be implemented in a project of your MYOB Acumatica extension library.

To create a built-in definition, follow the instructions in this topic.

To Create a Built-In Definition

  1. In a project of your MYOB Acumatica extension library, define a class that implements the PX.PushNotifications.Sources.IInCodeNotificationDefinition interface. The following code demonstrates the definition of such a class.
    using PX.PushNotifications.Sources;
    
    public class TestInCodeDefinition : IInCodeNotificationDefinition
    {
    }
  2. In the class that implements the IInCodeNotificationDefinition interface, implement the GetSourceSelect() method of the interface so that the method satisfies the following requirements:
    • The method must return a tuple of a BqlCommand object, which defines the data query, and a PXDataValue array, which defines the parameters that should be passed to the query.
    • The data query that the method defines should adhere to Recommendations for the Data Queries in the Integration Development Guide.
    The following example shows the GetSourceSelect() method implementation.
    using PX.Data;
    using PX.PushNotifications.Sources;
    using PX.PushNotifications.UI.DAC;
    
    public class TestInCodeDefinition : IInCodeNotificationDefinition
    {
      public Tuple<BqlCommand, PXDataValue[]> GetSourceSelect()       
      {           
        return               
          Tuple.Create(
            PXSelectJoin<PushNotificationsHook,
            LeftJoin<PushNotificationsSource,
              On<PushNotificationsHook.hookId, 
                Equal<PushNotificationsSource.hookId>>>>
            .GetCommand(), new PXDataValue[0]);       
      }
    }
  3. In the class that implements the IInCodeNotificationDefinition interface, implement the GetRestrictedFields() method of the interface so that the method satisfies the following requirements:
    • The method must return an array of IBqlField-derived types, which contains the fields that should be returned from the query.
    • If you need to return all fields, the method must return null.
    The following code shows an example of the implementation of the GetRestrictedFields() method.
    using PX.Data;
    using PX.PushNotifications.Sources;
    using PX.PushNotifications.UI.DAC;
    
    public class TestInCodeDefinition : IInCodeNotificationDefinition
    {
      ...
    
      public Type[] GetRestrictedFields()       
      {           
        return new [] 
        {
          typeof(PushNotificationsHook.address), 
          typeof(PushNotificationsHook.type), 
          typeof(PushNotificationsSource.designID), 
          typeof(PushNotificationsSource.inCodeClass), 
          typeof(PushNotificationsSource.lineNbr)
        };       
      }
    }
  4. Build the project of your MYOB Acumatica extension library.
  5. On the Built-In Definitions tab of the Push Notifications (SM302000) form, make sure that you can select the new built-in definition by its class name. The class of the built-in 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.
    Note: You can obtain the results of the data query defined with a built-in definition by using the following endpoint: http(s)://<MYOB Acumatica instance URL>/PushNotifications/<full class name of the built-in 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 MYOB Acumatica 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.