Monday, 6 February 2017

Dynamically Activate Extensions

Hi All,

Today I want to share with the way how you can enable and disable extensions dynamically.

You know that when you have published extension as a DLL or a Code file it will be automatically discovered by Acumatica Framework and used.
However there is a hidden way to stop Acumatica from usage of that extension. Do do that you just need add static method IsActive() to your extension.
  public class GL_Batch_Ext PXCacheExtension<PX.Objects.GL.Batch>
      public static bool IsActive()
        return false;
Acumatica will automatically call that method by signature (you need to have correct name, public, static and return bool) and if it returns False, extensions will be ignored.
That works the same way for Graph and Cache extensions.
Also note, that if method rise an exception extension will be loaded any way.

Good thing about it that you really can decide dynamically what extension should be loaded based on database value or current company.So that is a way how you can have different business logic customization for different companies.

So in that example I have renamed one of fields on Journal Entry screen based on current company id:
Have a nice development!


dangminhhuynh said...

Hi Sergey,
Thank for your post. I would like to ask is that limitation about version of using this kind of customization? Which version should be use for that?

Sergey Marenich said...

Hi Dang,
That should work starting from 4.2

George Wilson said...

DLL files contains the necessary data that helps running Window programs flawlessly. Therefore, it becomes necessary for the computer user to understand the cause of DLL errors and try fixing them as soon as possible.