-->

SugarCRM installable changes in detailview

2020-07-18 05:51发布

问题:

I have a simple problem but may be serious for me , I made custom fields and added them all in the custom\modules\Leads\metadata\detailviewdefs.php (detailview layout) of Leads module but problem is that i have to make a installer package of changes. I managed with custom fields and copied them in the custom\Extension\modules\Leads\Ext\Vardefs through manifest. Now i don't know how to apply detailviewdefs changes through manifest (add new fields panel in detailview). The point is that the existing detailview layout should not be changed but only add a new panel in it.

Possible solution in my mind is like I should add code in $layout_defs array $layout_defs["Leads"]["DetailView"] ['panels']['panel_name'] and place it in custom\Extension\modules\Leads\Ext\Layoutdefs\ and copy Layoutdefs file through manifest. I tried this but not seems working one. Looking for a smart solution share if you can.

Addition: Even if i export module changes from Studio ->export Customizations and import in other instance with module builder. It override all the previous custom files(customizations) in newer instance (Is it not a limitation in SugarCRM) but my requirement is to add only changes in newer instance's detailview.

回答1:

That's a tough one. There are two options that I know of. 1) Provide directions to the user for how to add the fields to the layouts using Studio 2) In a post_install.php script mimic how a Studio layout deploy works to insert your fields into any given layout (best practice would be to create a new panel for all of your fields if mass distributing).



回答2:

I had found following functions of sugar's ModuleInstaller class to add or remove fields from layouts through manifest script. These functions will add/remove fields to both editview and detail view at the same time. Just add following lines in post_install / pre_install no need to require anything,

   $installer_func = new ModuleInstaller();
   $layoutAdditions = array('Users' => 'users_access');

To add users_access field in Users module:

   $installer_func->addFieldsToLayout($layoutAdditions);

To remove users_access field from Users module:

   $installer_func->removeFieldsFromLayout($layoutAdditions);

Hope it's helping.

mansoor



标签: sugarcrm