Skip to content

Instantly share code, notes, and snippets.

@betobaz
Last active August 4, 2016 12:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save betobaz/4a2a7266e7afda8e83ad to your computer and use it in GitHub Desktop.
Save betobaz/4a2a7266e7afda8e83ad to your computer and use it in GitHub Desktop.
SugarCRM: Sidecar: Multi select dependent from another multi select dependent fields
<?php
$app_list_strings['promocion_region_list']=array (
'Michoacana' => 'Michoacana',
'Jaliciense' => 'Jaliciense',
'Sinaloense' => 'Sinaloense',
'Sonorense' => 'Sonorense',
);
$app_list_strings['seg_geo_com_Michoacana_list']=array (
'MO' => 'Morelia',
'UR' => 'Uruapan',
'ZI' => 'Zitacuaro',
'ZA' => 'Zamora',
);
$app_list_strings['seg_geo_com_Jaliciense_list']=array (
'TL' => 'Tlaquepaque',
'LM' => 'Lagos',
'CO' => 'Colima',
);
$app_list_strings['seg_geo_com_Sinaloense_list']=array (
'MZ' => 'Mazatlan',
'TE' => 'Tepic',
'MC' => 'Mochis',
'CU' => 'Culiacan',
);
$app_list_strings['seg_geo_com_Sonorense_list']=array (
'HE' => 'Hermosillo',
'OB' => 'Obregon',
'CA' => 'Caborca',
);
$app_list_strings['promocion_sucursal_list']=array (
'MO' => 'Morelia',
'UR' => 'Uruapan',
'ZI' => 'Zitacuaro',
'ZA' => 'Zamora',
'TL' => 'Tlaquepaque',
'LM' => 'Lagos',
'CO' => 'Colima',
'MZ' => 'Mazatlan',
'TE' => 'Tepic',
'MC' => 'Mochis',
'CU' => 'Culiacan',
'HE' => 'Hermosillo',
'OB' => 'Obregon',
'CA' => 'Caborca',
);
({
extendsFrom: "RecordView",
initialize: function(){
this._super('initialize', arguments);
var self = this;
this.model.on('change:region', _.bind(self._handlerSucursales, self));
}
_handlerSucursales: function(){
var self = this;
if(self.currentState === 'view') return;
var sucursal = this.getField('sucursal');
if(!sucursal) return;
var options = {};
// Obtener la listas de las companias seleccionadas
var values = self.model.get('region');
_.each(values, function(item, index){
var listStringsName = "seg_geo_com_"+item+"_list";
options = _.extend(options, app.lang.getAppListStrings(listStringsName));
});
self.model.set('sucursal', []);
sucursal.items = options;
sucursal.render();
}
})
<?php
$dictionary['Promociones'] = array(
'table' => 'qs_promociones',
'audited' => true,
'activity_enabled' => false,
'duplicate_merge' => true,
'fields' => array (
'region' =>
array (
'required' => false,
'name' => 'region',
'vname' => 'LBL_REGION',
'type' => 'multienum',
'massupdate' => true,
'default' => '',
'no_default' => false,
'comments' => '',
'help' => '',
'importable' => 'true',
'duplicate_merge' => 'enabled',
'duplicate_merge_dom_value' => '1',
'audited' => false,
'reportable' => true,
'unified_search' => false,
'merge_filter' => 'disabled',
'calculated' => false,
'size' => '20',
'options' => 'promocion_region_list',
'dependency' => '',
'isMultiSelect' => true,
),
'sucursal' =>
array (
'required' => false,
'name' => 'sucursal',
'vname' => 'LBL_SUCURSAL',
'type' => 'multienum',
'massupdate' => true,
'default' => '',
'no_default' => false,
'comments' => '',
'help' => '',
'importable' => 'true',
'duplicate_merge' => 'enabled',
'duplicate_merge_dom_value' => '1',
'audited' => false,
'reportable' => true,
'unified_search' => false,
'merge_filter' => 'disabled',
'calculated' => false,
'size' => '20',
'options' => 'promocion_sucursal_list',
'dependency' => '',
'isMultiSelect' => true,
),
),
);
@gonzaiglesias
Copy link

Hi Betobaz,

I been struggling with this, but I can't figure out how to get this done. On the console I have this error:

myField.render is not a function

What do you think it could be wrong?
Thanks in advance!

Gonzalo Iglesias

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment