0

I have two customization projects in Acumatica 2020R2. I need to reference a DAC from one of the customization projects in another customization project. The Acumatica instance that has one of the customization projects may or may not have both customization projects published.

For instance, a graph in one customization project may need to reference the VendorRebate DAC that was created in another customization project to check if a customer has a rebate for a particular inventory item before setting a price.

  • Is there a way to reference the DAC without having to include the DAC in both customization projects?
  • Also, is there a way to check if the Acumatica instance has the necessary customization project published (besides using conditional compilation)?
user10605996
  • 37
  • 1
  • 7
  • Maybe someone else has a solution, but... If the DAC is in a project that is not published, how would you expect to access it? Once a project is published in an instance, the database will contain the tables and fields. Without the project published to define how to access those tables/fields, you would need to define the DAC in your new project. There are ways to reference another DLL in Visual Studio, but then you run the risk of your project having a stale copy of the real DLL managed by the other project. Also, if you define the DAC's differently, you can end up with data corruption. – Brian Stevens Mar 26 '21 at 13:39
  • Ok. I was putting the DACs in both projects, and I was considering referencing the DLLs. I figured I'd see if there was a better way to accomplish this in Acumatica, but I guess I'll just have to remember to update the DAC in both projects whenever I change it in one. – user10605996 Mar 26 '21 at 13:43
  • personally, I would make a base project that contains the absolute base code, such as this DAC. Then it is accessible to every project that is layered on top. I suspect there is a way to do what you are attempting, but my greatest concern is data corruption caused different definitions of the same table. – Brian Stevens Mar 26 '21 at 13:46
  • My other option is to combine the customization projects and set up licensing for the different features, but this is what I was trying to avoid. I think my only other option is to be very careful to keep the definitions of the DACs in sync. – user10605996 Mar 26 '21 at 13:51

1 Answers1

1

Is there a way to reference the DAC without having to include the DAC in both customization projects?

First of all, if the projects are ever going to be published together you should never create duplicate DAC definitions. This can lead to crashes at runtime. It doesn't matter that the DAC are identical. Acumatica Framework will not be able to resolve the conflicts properly in all scenarios for identical types. This typically results in error can't cast object of type X to object of type Y.

Also, is there a way to check if the Acumatica instance has the necessary customization project published (besides using conditional compilation)?

Use the 'Validate Customization Project' action from the customization Publish menu. Unless you dynamically load DLL references you won't be able to publish.

The Acumatica instance that has one of the customization projects may or may not have both customization projects published.

To reference a type it has to be published, otherwise it is just inaccessible.

The most common option for your use case is to create a third customization project/DLL that contains the shared types.

Otherwise you can try to conditionally deactivate feature using the IsActive property.

DAC IsActive reference: https://help-2021r1.acumatica.com/Help?ScreenId=ShowWiki&pageid=9ca4cca5-a46c-4dda-af09-8cb8b0793c34

Graph IsActive reference: https://help-2021r1.acumatica.com/Help?ScreenId=ShowWiki&pageid=cd70b408-b389-4bd8-8502-3d9c12b11112

To load the referenced type only when it exists you would need to put it in a DLL first and load this DLL dynamically at runtime: https://stackoverflow.com/a/18362459/7376238

Hugues Beauséjour
  • 8,067
  • 1
  • 9
  • 22