[Vtigercrm-developers] VTiger Extension Module create custom field for Invoice Module
Lennart van Ballegoij
lennart at egmmedia.nl
Mon Feb 1 14:32:24 GMT 2016
Hi guys,
I'm working on a VTiger 6.4.0 Extenstion Module that sends the invoicedata
to a 3rd party API.
I'm trying to create a picklist field in the Invoice module from within my
module.
My module was already released and some clients are already using this
module, so i'll have to create the field on the module update.
But i can't seem to add the picklist field on module.preupdate or
module.postupdate of the vtlib_handler in my module.
If i uninstall/remove my module completely and add the picklist field using
the module.postinstall of the vtlib_handler it does seem to create the
field like it's supposed to.
Why can't i seem to create the field on the update events of the
vtlib_handler ?
My code:
public function vtlib_handler($moduleName, $eventType) {
if ($eventType == 'module.postinstall') {
$this->createConfigTable();
$this->registerInvoiceEvent();
$this->addSettingsMenu();
$this->addTypeDropdown();
} else if ($eventType == 'module.enabled') {
$this->registerInvoiceEvent();
} else if ($eventType == 'module.disabled') {
$this->deregisterInvoiceEvent($moduleName);
} else if($event_type == 'module.preupdate') {
$this->addSettingsMenu();
} else if($event_type == 'module.postupdate') {
$this->addTypeDropdown(); //Trying to create my Picklist field here !
} else if($event_type == 'module.preuninstall') {
$this->deleteConfigTable();
$this->deregisterInvoiceEvent($moduleName);
}
}
public function addTypeDropdown(){
$module = Vtiger_Module::getInstance('Invoice');
$blockInstance =
Vtiger_Block::getInstance('LBL_INVOICE_INFORMATION', $module);
$fieldInstance = new Vtiger_Field();
$fieldInstance->name = 'typeofinvoice';
$fieldInstance->label = 'Soort factuur';
$fieldInstance->table = 'vtiger_invoice';
$fieldInstance->column = $fieldInstance->name;
$fieldInstance->columntype = 'VARCHAR(100)';
$fieldInstance->uitype = 15; //15 Staat voor dropdown.
$fieldInstance->typeofdata = 'V~M';
$fieldInstance->summaryfield = 1; //Display in summaryview.
$fieldInstance->setPicklistValues( Array ('Factuur',
'Creditfactuur') );
$blockInstance->addField($fieldInstance);
}
Hopefully someone can give me a push in the right direction.
Thanks in advance :)
Lennart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20160201/92427fcb/attachment.html>
More information about the vtigercrm-developers
mailing list