Come aggiungere un qualsiasi campo all'Aggiornamento Globale in SugarCRM CE 6.5 o SuiteCRM
Come impostazione predefinita, SugarCRM CE 6.5 (e anche SuiteCRM) consente l'inserimento nell'Aggiornamento Globale solo dei campi di Tipo Dato:
- Checkbox
- Datetime
- Date
- DropDown
- DropDown Dinamico
- Intero
- Selezione Multipla
- Radio
Ho però trovato un metodo Upgrade-Safe per poter aggiungere un campo qualsiasi all'Aggiornamento Globale.
Innanzitutto è possibile aggiungere all'Aggiornamento Globale anche campi per i quali SuiteCRM non consente di attivare l'Aggiornamento Globale da Studio, come ad esempio i campi "Relate" o "Collega".
Per farlo occorre creare un file in custom/Extension/modules/<nomemodulo>/Ext/Vardefs con scritto:
<?php
$dictionary['<nomemodulo>']['fields']['<nomecampo>']["massupdate"] = true;
?>
Eseguendo un "Ripara Velocemente e Ricostruisci", il campo potrebbe essere già attivo nell'Aggiornamento Globale.
Per alcuni tipi di campo, però, l'Aggiornamento Globale non è gestito, per esempio per i campi di tipo "TextArea", ma è possibile gestirlo personalizzando l'Aggiornamento Globale stesso.
Per prima cosa creiamo un file custom/include/CustomMassUpdate.php così fatto:
<?php
// Extension of class MassUpdate to allow MassUpdate of field of type TextArea
if (! defined('sugarEntry') || ! sugarEntry)
die('Not A Valid Entry Point');
require_once('include/MassUpdate.php');
class CustomMassUpdate extends MassUpdate {
/**
* Override of this method to allow MassUpdate of field of type TextArea
* @param string $displayname field label
* @param string $field field name
* @param bool $even even or odd
* @return string html field data
*/
protected function addDefault($displayname, $field, &$even) {
if ($field["type"] == 'varchar') {
$even = ! $even;
$varname = $field["name"];
$displayname = addslashes($displayname);
$html = <<<EOQ
<td scope="row" width="20%">$displayname</td>
<td class="dataField" width="30%"><textarea name="$varname" style="width: 90%;" id="mass_{$varname}"></textarea></td>
EOQ;
return $html;
}
else
return '';
}
}
?>
Perché questa estensione venga utilizzata, occorre creare un file custom/include/CustomListViewSmarty.php così:
<?php
// Extension of class ListViewSmarty to allow MassUpdate of field of type TextArea
if (! defined('sugarEntry') || ! sugarEntry)
die('Not A Valid Entry Point');
require_once('include/ListView/ListViewSmarty.php');
require_once('custom/include/CustomMassUpdate.php');
class CustomListViewSmarty extends ListViewSmarty {
/**
* @return MassUpdate instance
*/
protected function getMassUpdate() {
return new CustomMassUpdate();
}
}
?>
Eseguendo un "Ripara Velocemente e Ricostruisci", i campi di tipo TextArea dovrebbero essere gestiti dall'Aggiornamento Globale.
Problemi? Contattaci per una consulenza professionale su SugarCRM CE o SuiteCRM.