Site Configuration using Customization

Hi All,

Acumatica as most of web applications has some configurations that are stored on the file system. For example it can be a web.config or any other file that is stored in Site folder itself.

configurations acumatica

During upgrade procedure Acumatica overrides all standard files to ensure that system will work correctly with all latest platform changes correctly. This is correct, as any automatic merge of configurations can cause to compilation errors. This is especially harmful if you site is in public cloud and you have no access to the instance.
So that means if you do custom configuration (like redirection rules, filters or custom controls) your changes most probably will be lost right after update. There are several exceptions when configurations will not be overridden:

  • You keep configurations in separate (not standard) file. Acumatica will not touch any file that is included into standard Acumatica.
  • Some specific changes can be preserved by Acumatica Configuration wizard. Connection String, Active Directory, SSO, timeouts are the example of preserved configurations.

But what to do if you really want to reconfigure something?

Disclaimer: Please note that all manual changes in the standard Acumatica in the way that is not recommended in appropriate Development and Customization guides are not supported.
If you still have it or want to have – use it at your own risk. Acumatica cannot support and guarantee that your changes will work in the future.
With great power comes great responsibility!

Ok, still want to have some reconfiguration? In this case better to ensure that your changes will be applied automatically with Instance upgrade.

Luckily Acumatica has a place where you can code such things – Customization Plug-In. Customization Plug-In is a separate code file with class that Acumatica can dynamically compile and load during publication process. Class events will be automatically subscribed and executed on Database or/and Files operations.
Note that customization plug-in should be in customization project itself as a code file. If you include it into the customization DLL it might not been executed.
Also note that that OnPublished event (described below) is depend on UseRuntimeCompilation key in web config. If Acumatica cannot compile and run code dynamically this method may not be executed.  Execution of the UpdateDatabase method does not depend on the UseRuntimeCompilation key value.

There are 2 events:

  • OnPublished – here you can access file system and do proper configuration prior application be restarted.
  • UpdateDatabase – here you can have some operations that should be executed to ensure your own database update scripts.

Note that customization plug-in should be used as exception. Put update procedures in other places where it is possible.

Here I have short example, how we can add (or change) packages configuration in Acumatica ERP right from Customization
Code snippet:

On the publication, you will see new comments in the log window:

comments in acumatica

That means that your code has been executed and new config has been applied.

Have a safe customization!

Leave a Reply

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