[Vtigercrm-developers] VTiger Extension Module create custom field for Invoice Module
Tim Mohrbach
preexo at googlemail.com
Mon Feb 1 16:10:08 GMT 2016
I would have done it the same way, remember to increase the version number of the extension in the schema xml file… sry mate I am bad help…
I have always wondered about this: does it try to create a new field everytime it updates the extension or is the addField method tolerant enough to ingore the field in case it’s already there?
> On 01.02.2016, at 22:32, Lennart van Ballegoij <lennart at egmmedia.nl> wrote:
>
> 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
>
>
> _______________________________________________
> http://www.vtiger.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20160202/0355f5dd/attachment.html>
More information about the vtigercrm-developers
mailing list