4

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.

Mansoor Jafar
  • 1,458
  • 3
  • 15
  • 31

2 Answers2

2

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).

egg
  • 1,736
  • 10
  • 12
  • tHank's @egg to answer, first option is not suitable in my case as my fields are not so simple to add just from studio(having customcode), so i'm now going toward 2nd option and expecting it can solve my problem... – Mansoor Jafar Oct 11 '12 at 06:09
1

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

Mansoor Jafar
  • 1,458
  • 3
  • 15
  • 31
  • Your solution sounds interesting.But let me know if I can add the new element with custom js code eg : onblur of some textbox.Also if there is an existing element eg: first_name in COntacts and i want to add onblur function on it.How can I do this? – user3286692 Mar 07 '14 at 02:48