[Vtigercrm-developers] VTiger Extension Module create custom field for Accounts Module

Conrado Maggi comaggi at gmail.com
Wed Nov 25 16:01:14 GMT 2015


Hello,

Yes, calling the field creating script from the module.postinstall event is
the right way to do it.

You should consider removing all you are adding in the module.preuninstall
 event


Cheers,
Conrado

On Wed, Nov 25, 2015 at 3:28 PM, Lennart van Ballegoij <lennart at egmmedia.nl>
wrote:

> I'm working on a VTiger 6.4.0 Extension Module that is used to get company
> data when entering a company name in the Accounts module.
>
> The module is almost finished, i retrieve data from a API and enter them
> in the input fields using JQuery.
>
> But the problem is that i have some data that is not relative to the
> existing fields in the account information, so i'm trying to create some
> new custom fields.
>
> Only i can't seem to figure out how to create a custom field for the
> Accounts module from within my module.
>
> I googled around and watched some posts on stackoverflow.
>
> I came up with the following part of code, but this doesn't seem to work.
>
> public function addKvkfield(){
>
>     $module = new Vtiger_Module();
>     $module->name = 'Accounts';
>     $module = $module->getInstance('Accounts');
>
>     $blockInstance = new Vtiger_Block();
>     $blockInstance->label = 'LBL_ACCOUNT_INFORMATION';
>     $blockInstance = $blockInstance->getInstance($blockInstance->label,$module);
>
>     $fieldInstance = new Vtiger_Field();
>     $fieldInstance->name = 'KvKNummer';
>     $fieldInstance->table = $module->basetable;
>     $fieldInstance->column = 'kvknummer';
>     $fieldInstance->columntype = 'VARCHAR(100)';
>     $fieldInstance->uitype = 2;
>     $fieldInstance->typeofdata = 'V~M';
>     $blockInstance->addField($fieldInstance);
> }
>
> The addKvkfield function is being called in the vtlib_handler
> module.postinstall (Couldn't find any information if this is the right way
> of doing this within a Module)
>
> vtlibhandler:
>
> function vtlib_handler($modulename, $event_type) {
>     global $log;
>     if($event_type == 'module.postinstall') {
>         $this->addJSLinks();
>         $this->createConfigTable();
>         $this->addSettingsMenu();
>         $this->addKvkfield();
>         $this->updateLabels();
>
>         // TODO Handle post installation actions
>     } else if($event_type == 'module.disabled') {
>         // TODO Handle actions when this module is disabled.
>     } else if($event_type == 'module.enabled') {
>         // TODO Handle actions when this module is enabled.
>     } else if($event_type == 'module.preuninstall') {
>         // TODO Handle actions when this module is about to be deleted.
>     } else if($event_type == 'module.preupdate') {
>         // TODO Handle actions before this module is updated.
>     } else if($event_type == 'module.postupdate') {
>         $this->updateLabels();
>         // TODO Handle actions after this module is updated.
>     }
> }
>
> Hopefully someone can give me a push in the right direction.
>
> Thanks in advance :)
>
> _______________________________________________
> http://www.vtiger.com/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20151125/ab1ba668/attachment.html>


More information about the vtigercrm-developers mailing list