Skip to main content
Solved

Cannot insert data using database scripts feature


Forum|alt.badge.img

I am using the customization project function. To insert my data into the database with the tables as updateFile and UploadFile when I Publish. So I wrote a script to be able to insert the data into the database script section.


. But I got a message from Acu's support team that I can't do it this way.

 

So is there any other way for me to help fulfill the above requirement?

Best answer by Evgeny Afanasiev

Hi Phat,

Yes, as per requirement custom SQL scripts are forbidden, beside some specific cases, although definition for both MSSQL and MySQL would be needed.

Please use Files section in the Customization Project Editor in order to add the file to the customization project. For this I would suggest to place the file in the desired location on your development instance first, so when you would add the file to the customization project, the path will be saved as well. This way it will be deployed in the same path on production instance.
 

If it is an image and your requirement is to use it just for UI for your custom screen, then it should be possible to use it straight away without serializing it to DB. If you need it in Database as a File, you can use the UploadFileMaintenance graph instance in the implementation of your Customization Plug-in.

View original

Evgeny Afanasiev
Acumatica Moderator
Forum|alt.badge.img

Hi Phat,

Yes, as per requirement custom SQL scripts are forbidden, beside some specific cases, although definition for both MSSQL and MySQL would be needed.

Please use Files section in the Customization Project Editor in order to add the file to the customization project. For this I would suggest to place the file in the desired location on your development instance first, so when you would add the file to the customization project, the path will be saved as well. This way it will be deployed in the same path on production instance.
 

If it is an image and your requirement is to use it just for UI for your custom screen, then it should be possible to use it straight away without serializing it to DB. If you need it in Database as a File, you can use the UploadFileMaintenance graph instance in the implementation of your Customization Plug-in.


Leonardo Justiniano
Jr Varsity I
Forum|alt.badge.img+5

Hi @phat 

 

I suggest you implement that insertion after your package is published through Plugins. There is an event after publishing on the context of each tenant where you can take care of data setups and adjustments.

 

public class SXPlugIn : CustomizationPlugin
{
   //This method executed after customization was published and website was restarted.  
   public override void UpdateDatabase()
   {
      MyGraphMaint graph = PXGraph.CreateInstance<MyGraphMaint>();
      if(graph.MySetupLogic(...))
      {
           this.WriteLog(string.Format("Data adjusted in {0}.", PXInstanceHelper.CurrentCompany));
      }			
    }
 }

Inside “MySetupLogic” you code normal Acumatica framework logic with Caches interactions etc.

This why you become database agnostic and avoid any error you might have running your SQL script.

 

Hope this help


Joe Schmucker
Captain II
Forum|alt.badge.img+3
Leonardo Justiniano wrote:

Hi @phat 

 

I suggest you implement that insertion after your package is published through Plugins. There is an event after publishing on the context of each tenant where you can take care of data setups and adjustments.

​​​@Leonardo Justiniano 

I need to do something similar to this.  Does this Plugin need to be in a separate package, or can I put this code in my main VS application?

 


Joe Schmucker
Captain II
Forum|alt.badge.img+3

@Leonardo Justiniano Nevermind that...I just put it in my project.  WORKED AWESOME!!!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings