[Vtigercrm-developers] Error trying to save a new Record of a new Custom module
    Juan Pablo Botero 
    juanpabloboterolopez at gmail.com
       
    Wed Aug 22 08:08:35 PDT 2012
    
    
  
2012/8/22 Adam Heinz <amh at metricwise.net>
> On Tue, Aug 21, 2012 at 5:39 PM, Juan Pablo Botero
> <juanpabloboterolopez at gmail.com> wrote:
> > I added before the two die statement, i think is more comfortable that i
> > attach a document with the output.
>
> The stack trace definitely has some problems.
>
> #0 checkFileAccessForInclusion(modules//.php) called at [<root of
> vtiger>/data/CRMEntity.php:54]
> #1 CRMEntity::getInstance() called at [<root of
> vtiger>/include/events/VTEntityData.inc:37]
> #2 VTEntityData::fromEntityId(<db>, 17)
>
> It looks to me like either crmid 17 does not exist in the database, or
> has no setype (which is the name of the governing module).  You
> created this module with vtlib?  Would you be opposed to posting that
> code?
>
No problem:
include_once('./vtlib/Vtiger/Module.php');
 include_once('./vtlib/Vtiger/Menu.php');
 $modulo = new Vtiger_module();
 $modulo->name = 'Beneficiarios';
 $modulo->save();
 $modulo->initWebService();
// Init tables in database
 $modulo->initTables();
 // Add new module in menu Sales
 $menu = Vtiger_Menu :: getInstance('Sales');
 $menu->addModule($modulo);
 /**
  * BASIC DATA BLOCK
  */
 $bloqueDatosBasicos = new Vtiger_Block();
 $bloqueDatosBasicos->label = 'LBL_BENEFICIARIO_INFORMATION';
 $modulo->addBlock($bloqueDatosBasicos);
 /**
  * EXTRA DATA BLOCK
  */
 $bloqueDatosExtra = new Vtiger_Block();
 $bloqueDatosExtra->label = 'LBL_CUSTOM_INFORMATION';
 $modulo->addBlock($bloqueDatosExtra);
 /**
  * CREATING MODULE FIELDS
  */
 $campoNombre = new Vtiger_Field();
 $campoNombre->name = 'nombreBeneficiario';
 $campoNombre->label = 'Nombre';
 // database fields
 $campoNombre->table = $modulo->basetable;
 $campoNombre->column = 'nombreBeneficiario';
 $campoNombre->columntype = 'VARCHAR(100)';
 $campoNombre->uitype = 2;
 $campoNombre->typeofdata = 'V~M';
 $bloqueDatosBasicos->addField($campoNombre);
 $modulo->setEntityIdentifier($campoNombre)
 $campoTelfijo = new Vtiger_Field();
 $campoTelfijo->name = 'telefonoFijoBeneficiario';
 $campoTelfijo->label = 'Telefono Fijo';
 $campoTelfijo->table = $modulo->basetable;
 $campoTelfijo->column = 'telefonoFijoBeneficiario';
 $campoTelfijo->uitype = 2;
 $campoTelfijo->typeofdata = 'V~O';
 $bloqueDatosBasicos->addField($campoTelfijo);
 $modulo->setEntityIdentifier($campoTelfijo);
 $campoTelMovil = new Vtiger_Field();
 $campoTelMovil->name = 'telefonoMovilBeneficiario';
 $campoTelMovil->label = 'Telefono movil';
 $campoTelMovil->table = $modulo->basetable;
 $campoTelMovil->column = 'telefonoMovilBeneficiario';
 $campoTelMovil->uitype = 2;
 $campoTelMovil->typeofdata = 'V~O';
 $bloqueDatosBasicos->addField($campoTelMovil);
 $modulo->setEntityIdentifier($campoTelMovil);
 $campoCedula = new Vtiger_Field();
 $campoCedula->name = 'cedulaBeneficiario';
 $campoCedula->label = 'Cedúla';
 $campoCedula->table = $modulo->basetable;
 $campoCedula->column = 'cedulaBeneficiario';
 $campoCedula->uitype = 2;
 $campoCedula->typeofdata = 'V~O';
 $bloqueDatosBasicos->addField($campoCedula);
 $modulo->setEntityIdentifier($campoCedula);
 $campoNacimiento= new Vtiger_Field();
 $campoNacimiento->name = 'nacimientoBeneficiario';
 $campoNacimiento->label = 'Fecha de nacimiento';
 $campoNacimiento->table = 'vtiger_crmentity';
 $campoNacimiento->column = 'nacimientoBeneficiario';
 $campoNacimiento->uitype = 70;
 $campoNacimiento->typeofdata = 'T~O';
 $bloqueDatosBasicos->addField($campoNacimiento);
 // el nombre del campo como identificador de campo
 $modulo->setEntityIdentifier($campoNacimiento);
 $campoCiudad= new Vtiger_Field();
 $campoCiudad->name = 'ciudadBeneficiario';
 $campoCiudad->label = 'Ciudad';
 $campoCiudad->table = $modulo->basetable;
 $campoCiudad->column = 'ciudadBeneficiario';
 $campoCiudad->columntype = 'VARCHAR(255)';
 $campoCiudad->uitype = 2;
 $campoCiudad->typeofdata = 'V~O';
 $bloqueDatosBasicos->addField($campoCiudad);
 // el nombre del campo como identificador de campo
 $modulo->setEntityIdentifier($campoCiudad);
 $campoDepartamento= new Vtiger_Field();
 $campoDepartamento->name = 'departamentoBeneficiario';
 $campoDepartamento->label = 'Departamento';
 $campoDepartamento->table = $modulo->basetable;
 $campoDepartamento->column = 'departamentoBeneficiario';
 $campoDepartamento->columntype = 'VARCHAR(255)';
 $campoDepartamento->uitype = 2;
 $campoDepartamento->typeofdata = 'V~O';
 $bloqueDatosBasicos->addField($campoDepartamento);
 // el nombre del campo como identificador de campo
 $modulo->setEntityIdentifier($campoDepartamento);
 $campoDireccion= new Vtiger_Field();
 $campoDireccion->name = 'direccionBeneficiario';
 $campoDireccion->label = 'Dirección Domicilio';
 $campoDireccion->table = $modulo->basetable;
 $campoDireccion->column = 'direccionBeneficiario';
 $campoDireccion->columntype = 'VARCHAR(255)';
 $campoDireccion->uitype = 2;
 $campoDireccion->typeofdata = 'D~O';
 $bloqueDatosBasicos->addField($campoDireccion);
 $modulo->setEntityIdentifier($campoDireccion);
 $campoIndicacion= new Vtiger_Field();
 $campoIndicacion->name = 'indicacionesDireccionBeneficiario';
 $campoIndicacion->label = 'Indicación Dirección';
 $campoIndicacion->table = $modulo->basetable;
 $campoIndicacion->column = 'indicacionDireccionBeneficiario';
 $campoIndicacion->columntype = 'VARCHAR(255)';
 $campoIndicacion->uitype = 19;
 $campoIndicacion->typeofdata = 'D~O';
 $bloqueDatosBasicos->addField($campoIndicacion);
 // el nombre del campo como identificador de campo
 $modulo->setEntityIdentifier($campoIndicacion);
 /*
  * RELATED FIELDS
  */
 // ACCOUNTS
 $campoCuenta= new Vtiger_Field();
 $campoCuenta->name = 'cuentaRelacionada';
 $campoCuenta->label = 'Cuenta';
 $campoCuenta->column = 'cuentaRelacionada';
 $campoCuenta->columntype = 'VARCHAR(100)';
 $campoCuenta->uitype = 10;
 $campoCuenta->typeofdata = 'V~O';
 $campoCuenta->helpinfo = 'Relaciona con una cuenta existente';
 $bloqueDatosBasicos->addField($campoCuenta);
 $campoCuenta->unsetRelatedModules(Array('Accounts', 'Contacts'));
 $campoCuenta->setRelatedModules(Array('Accounts')) ;
 //$modulo->setRelatedModules(Array('Accounts'));
 /**
  * ASSIGNED TO
  */
  $campoAsignado = new Vtiger_Field();
  $campoAsignado->name = 'id_usuario_asignado';
  $campoAsignado->label = 'Asignado a';
  $campoAsignado->table = 'vtiger_crmentity';
  $campoAsignado->column = 'smownerid';
  $campoAsignado->uitype = 53;
  $campoAsignado->typeofdata = 'V~O';
  $bloqueDatosExtra->addField($campoAsignado);
 /*
  * FILTER
  */
  $filtro1 = new Vtiger_Filter();
  $filtro1->name = 'Todo';
  $filtro1->isdefault = true;
  $modulo->addFilter($filtro1);
  // Campos del filtro1
  $filtro1->addField($campoNombre);
  //$filtro1->addField($campoApellido);
  $filtro1->addField($campoTelfijo);
  $filtro1->addField($campoDireccion);
  // Cambiar vista del módulo a privada
  $modulo->setDefaultSharing('Private');
  /**
   * RELATED LISTS
   */
   $moduloCuentas = Vtiger_Module::getInstance('Accounts');
   $etiquetaRelacion = 'Accounts';
   $modulo->setRelatedList($moduloCuentas, $etiquetaRelacion, Array('ADD',
'SELECT'));
  $modulo->enableTools(Array('Import', 'Export'));
  $modulo->disableTools('Merge');
Some of the fields doesn't create in database.
_______________________________________________
> http://www.vtiger.com/
>
-- 
Cordialmente:
Juan Pablo Botero
Administrador de Sistemas informáticos
Fedora Ambassador for Colombia
http://www.jpilldev.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20120822/1cf9fa4d/attachment.html 
    
    
More information about the vtigercrm-developers
mailing list