Platform API: Support for Multiple Implementations of the PXImport Functionality

In previous versions of MYOB Acumatica, a developer would rely on the IPXPrepareItems interface of the PXImportAttribute class to handle the import mechanism on a form. During customization, a developer had to implement all the members of this interface even if they were not actually needed. Also, there could only be one effective implementation of this interface per graph. This meant that this single implementation had to handle all the data views in a graph.

In MYOB Acumatica2024.1, this interface is now obsolete, and we recommend that developers use one of the following new interfaces, which offer more granular control for the handling of the import mechanism:

  • PXImportAttribute.IPrepare
  • PXImportAttribute.IImport
  • PXImportAttribute.IConfirm

A developer can now have multiple implementations of the interfaces listed above within a graph (or in one of its extensions), and each implementation can handle its own data view. These interfaces should be implemented in a graph (or in one of its extensions) that introduces an importable data view.

The following code example shows how to implement the new PXImportAttribute.IPrepare interface in a graph.

public class MyGraph : PXGraph<MyGraph>, PXImportAttribute.IPrepare
{
    ...
    [PXImport]
     public
        SelectFrom<...>.
        View MyImportableView
 
    bool PXImportAttribute.IPrepare.PrepareImportRow(string viewName, 
          IDictionary keys, IDictionary values)
    {
        /* Custom handlers must filter invocations that belong to their views */

        if (viewName == nameof(MyImportableView))
        {
            // prepare import
        }
        return true;
    }
}
    

The following code example shows how to implement the new PXImportAttribute.IPrepare interface in a graph extension.

public class MyGraphExtension : PXGraphExtension<MyGraph>, PXImportAttribute.IPrepare
{
    ...
    [PXImport]
     public
        SelectFrom<...>.
        View MyAnotherImportableView
 
    bool PXImportAttribute.IPrepare.PrepareImportRow(string viewName, 
          IDictionary keys, IDictionary values)
    {
        /* Custom handlers must filter invocations that belong to their views */

        if (viewName == nameof(MyAnotherImportableView))
        {
            // prepare import
        }
        return true;
    }
}
    

Note that when the PrepareImportRow handler is invoked in a graph or a graph extension for a particular data view, all of the other definitions of the PrepareImportRow handler in the graph or its extensions would be invoked as well. So a developer should check the first parameter of the PrepareImportRow handler to make sure they filter the invocation for their specific data view, as shown in the preceding code examples.