user10605996
user10605996

Reputation: 37

Use DAC from One Customization Project in Another Customization Project in Acumatica

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.

Upvotes: 0

Views: 396

Answers (1)

Hugues Beauséjour
Hugues Beauséjour

Reputation: 8288

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

Upvotes: 1

Related Questions