Apply Customization to all Graphs

Hi All,

Today want to share with you one tip how can you add customization to all graphs at once.

Please note, this is not recommended practice and may lead to the errors and performance degradation!

You know that you can define graph extension with specific graph – PXGraphExtension<PX.Objects.GL.JournalEntry>. However, all graphs are inherited from one base class ether PXGraph<TGraph> or PXGraph<TGraph, TPrimaryView>. In that case PXGraph is normal class and can be used as standalone object.
In terms of our customizations that means that we can create an extension for parent PXGraph and it will be used with any graph in the system automatically.

Here we have an example how can you add a special setup to any graph in Acumatica. Please note that we are using Initialize method instead of constructor because dataviews are not yet initialized when extension constructor is called.

public class PXGraph_Extension : PXGraphExtension<PXGraph>
{
        public PXSetup<PX.Objects.GL.GLSetup> GLSetup;

        public override void Initialize()
        {
                 Object row = GLSetup.Current;
        }
}

Warning: please be careful with using this method as if you have do any code mistake than this error will pops up on any graph in the system including customization graphs. So if your code throws an exception you may not be ably to access it with Customization Browser anymore as it also based on graphs.

Big thanks to Gabriel and Andrew for sharing knowledge for this article.
Have a nice development!

2 Replies to “Apply Customization to all Graphs”

  1. Hi Sergey, thank you for great suggestion!
    I have an issue on the 21R1 version with Persist method in the PXGraphExtension. I can’t login into the system. Error: “Database could not be accessed”
    Code:
    public class AllGraphsExtensions : PXGraphExtension
    {
    [PXOverride]
    public virtual void Persist(Action basePersist)
    {
    basePersist?.Invoke();
    }
    }

    1. Hi Vasyl,

      We are currently experiencing the same error you received.

      Did you ever find a workaround for this?

      Thanks,
      Shawn

Leave a Reply

Your email address will not be published. Required fields are marked *