Said Ait Haddou Ali
Read all my blogsCross deployment unit object creation (Businesspartner – Lead)
In SAP Hybris Cloud for Customer business objects are assigned to a particular Deployment Unit.
When developnig within a business object from the Foundation deployment unit, you will not be able to directly create an instance of a business object assigned to for instance the CRM deployment unit.
This issue has been addressed in the blog Understanding Deployment Units from Stefan Hagen. I encourage anyone who encounters Deployment Unit issues to go through that blog. It explains how to manage working with Custom Business Objects that reside in different Deployment Units.
In this blog I would like to discuss how to deal with situations where you would like to create objects, cross deployment units, from one standard business object to another. Let’s say we need to create a Lead (CRM Deployment Unit) from a Businesspartner (Foundation Deployment Unit). We can move a custom BO to the Leads’ Deployment Unit. This custom Business Object can now create Leads, but It cannot be changed by the Businesspartner to trigger the Lead creation. So what to do?
The Internal Communication object
In the SDK the Internal Communication object is made available. This special object automatically copies changes done in one custom BO and does the same changes in another custom BO. The two custom BOs do not need to be in the same Deployment unit. So, back to our case. We would like to be able to create a new Lead (CRM Deployment Unit) from a businesspartner (Foundation Deployment Unit). The approach would be to create two custom Helper BOs, one in each deployment units.
The two Helper BOs are connected by the Internal Communication object:
- The OnSave event of the Businesspartner contains the logic to determine whether a Lead should be created. If the Lead should be created, a change is triggered in the HelperBO_Foundation (create a new entry, or change an existing).
- The Internal Communication object picks up this change, and performs the same change in HelperBO_CRM. Its save event is triggered.
- In the save event of HelperBO_CRM we create a new Lead. This is possible since we are initiating the creation in the proper Deployment Unit.