AnsweredAssumed Answered

Autopopulate some custom fields from Accounts when creating a new record at custom module subpanel.

Question asked by Jaime Pérez on Apr 27, 2015
Hello, I am using Sugarcrm CE 6.5.18. What i try to do is to autopopulate some custom fields from Accounts when creating a new record at custom module subpanel.

I have it done with meetings via:
custom/Extension/modules/accounts/ext/layoutdefs/_overrideAccount_subpanel_account_meetings_1.php

i declared there the widget that does this tric at line 15:

 array ( 'widget_class' => 'SubPanelTopButtonQuickCreate',
 'widget_class' => 'SubPanelTopCreateIntervenciones'

Thats ok, and i had been able to populate the fields i require with this code in SugarWidgetSubPanelTopCreateIntervenciones.php at include/generic/sugarwidgets/

---





class SugarWidgetSubPanelTopCreateIntervenciones extends SugarWidgetSubPanelTopButtonQuickCreate
{
    public function getWidgetId()
    {
        return parent::getWidgetId();
    }

function display($defines)
{
  global $app_strings;
  global $currentModule;
 
 
  $title = $app_strings['LBL_NEW_BUTTON_TITLE'];
  //$accesskey = $app_strings['LBL_NEW_BUTTON_KEY'];
  $value = $app_strings['LBL_NEW_BUTTON_LABEL'];
  $this->module = 'Meetings';
  if( ACLController::moduleSupportsACL($defines['module'])  && !ACLController::checkAccess($defines['module'], 'edit', true)){
   $button = "<input title='$title'class='button' type='button' name='button' value='  $value  ' disabled/>\n";
   return $button;
  }
 
  $additionalFormFields = array();
  if(isset($defines['focus']->shipping_address_city)) 
   $additionalFormFields['ciudad_c'] = $defines['focus']->shipping_address_city;
  if(isset($defines['focus']->shipping_address_street)) 
   $additionalFormFields['jjwg_maps_address_c'] = $defines['focus']->shipping_address_street;
  if(isset($defines['focus']->shipping_address_postalcode)) 
   $additionalFormFields['cp_c'] = $defines['focus']->shipping_address_postalcode;
  if(isset($defines['focus']->relacionzonas_c)) 
   $additionalFormFields['zona_c'] = $defines['focus']->relacionzonas_c;
  if(isset($defines['focus']->relacionadministrador_c)) 
   $additionalFormFields['administrador_c'] = $defines['focus']->relacionadministrador_c;
  if(isset($defines['focus']->cuentabancaria_c)) 
   $additionalFormFields['ccc_c'] = $defines['focus']->cuentabancaria_c;
  if(isset($defines['focus']->description)) 
   $additionalFormFields['description'] = $defines['focus']->description;
  if(isset($defines['focus']->cobrodefacturas_c)) 
   $additionalFormFields['formadepagoadministrador_c'] = $defines['focus']->cobrodefacturas_c;
  

  
 
 
  $button = $this->_get_form($defines, $additionalFormFields);
  $button .= "<input title='$title' class='button' type='submit' name='{$this->getWidgetId()}' id='{$this->getWidgetId()}' value='  $value  '/>\n";
  $button .= "</form>";
  return $button;
}

---

The problem comes to me when trying to replicate the process with a custom module (not meetings), becouse noting happens and fields are empty when creating a new record.

Thankyou and sorry for my english.

Jaime Pérez

Outcomes