[Vtigercrm-developers] vtiger 7.0 cannot save record for custom module

lucia digirolamo l.digirolamo at websonica.net
Fri Sep 28 13:49:40 GMT 2018


I managed to create the missing table copying the one from leads. So I 
created the table with this:

CREATE TABLE IF NOT EXISTS `vtiger_chiamate_user_field` (
`recordid` int(25) NOT NULL,
`userid` int(25) NOT NULL,
`starred` varchar(100) DEFAULT NULL,
KEY `fk_chiamateid_vtiger_chiamate_user_field` (`recordid`)

Now the saving works and when I click the record it correctly opens and 
I can see all the details.

But now I have to add a uitype10 to the Accounts module. I used the 
following script:

// Turn on debugging level
$Vtiger_Utils_Log = true;

// Include necessary classes

// Define instances: add GUEST to HOST
// host = the module the uitype 10 needs to be created in
// guest == the module the user can access to via uitype10 field
$host = Vtiger_Module::getInstance('Chiamate');
$guest = Vtiger_Module::getInstance('Accounts');
$block = Vtiger_Block::getInstance('LBL_CHIAMATE_INFORMATION', $host);

// Add field
$field = new Vtiger_Field();
$field->name = 'account_id';
$field->label = 'Azienda';
$field->table = 'vtiger_account';
$field->column = 'account_id';
$field->columntype = 'VARCHAR(255)';
$field->uitype = 10;
$field->typeofdata = 'V~O';


$field->setRelatedModules(Array('Accounts')); // guest

The field is created correctly but the initial issue has come back. If I 
delete the new field, then the module works as expected.

Do I have to add a column for this new field in the 
vtiger_chiamate_user_field table?

Do I have to add only the uitype10 fields or do I have to add all the 
fields that are currently in my module?

Can anyone help? Thanks

On 28/09/2018 15:16, lucia digirolamo wrote:
> Hi,
> I've created a module via vtlib and added some fields via layout 
> editor. When I try to save a new record or opening an existing one, I 
> get the error message saying that the record is not found. The records 
> shows correctly in both vtiger_field and the table of my module. I 
> enabled vtiger logs and the query shows an error:
> PearDatabase ->ADODB error  Query Failed:SELECT vtiger_chiamate.name 
> AS vtiger_chiamatename,vtiger_crmentity.smownerid AS 
> vtiger_crmentityassigned_user_id,vtiger_crmentity.createdtime AS 
> vtiger_crmentitycreatedtime,vtiger_crmentity.modifiedtime AS 
> vtiger_crmentitymodifiedtime,vtiger_chiamatecf.cf_1113 AS 
> vtiger_chiamatecfcf_1113,vtiger_chiamatecf.cf_1115 AS 
> vtiger_chiamatecfcf_1115,vtiger_chiamatecf.cf_1119 AS 
> vtiger_chiamatecfcf_1119,vtiger_chiamatecf.cf_1121 AS 
> vtiger_chiamatecfcf_1121,vtiger_chiamatecf.cf_1123 AS 
> vtiger_chiamatecfcf_1123,vtiger_chiamatecf.cf_1125 AS 
> vtiger_chiamatecfcf_1125,vtiger_crmentity.deleted, 
> vtiger_crmentity.label FROM  vtiger_crmentity LEFT JOIN 
> vtiger_chiamate ON (vtiger_chiamate.chiamateid = 
> vtiger_crmentity.crmid  ) LEFT JOIN vtiger_chiamatecf ON 
> (vtiger_chiamatecf.chiamateid = vtiger_crmentity.crmid  ) LEFT JOIN 
> vtiger_chiamate_user_field ON (vtiger_chiamate_user_field.recordid = 
> vtiger_crmentity.crmid  AND vtiger_chiamate_user_field.userid = 1 ) 
> WHERE vtiger_crmentity.crmid=?  LIMIT 1::->[1146]Table 
> 'linkcrm.vtiger_chiamate_user_field' doesn't exist
> I checked in my database and in fact the table 
> vtiger_chiamate_user_field doesn't exist. But how am I supposed to 
> create it? Which fields does this table need? There are costraints to 
> apply (I imagine so)?
> Can anybody help me?

More information about the vtigercrm-developers mailing list