[Vtigercrm-developers] VTiger Extension Module create custom field for Invoice Module
Lennart van Ballegoij
lennart at egmmedia.nl
Thu Feb 18 14:48:48 GMT 2016
Hi Guys,
Nobody knows the answer to this ?
I really don't want to tell my clients that the module needs to be
reinstalled, because most of them won't even understand how to delete the
module folders from the FTP.
I hope someone can help me.
Thanks in advance,
Kind regards,
-
Lennart
2016-02-03 15:45 GMT+01:00 Lennart van Ballegoij <lennart at egmmedia.nl>:
> Thanks for the tip, i forgot about the version number!
>
> I've wondered about the same thing, but so far it seems like the field
> doesn't get created on update at all.
> I'm starting to wonder if it's even possible to create the field on a
> update event... :/
>
> So far i've had no luck in creating the field on update, i'm almost 100%
> sure that i'm doing the field creation right, because it does work on a
> fresh install of the module.
>
> Really hope someone knows the answer to this.
>
>
> Thanks in advance,
>
> Kind regards,
>
> -
>
> Lennart
>
> 2016-02-01 17:10 GMT+01:00 Tim Mohrbach <preexo at googlemail.com>:
>
>> 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/
>>
>>
>>
>> _______________________________________________
>> http://www.vtiger.com/
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20160218/d736e6c8/attachment.html>
More information about the vtigercrm-developers
mailing list