<div dir="ltr"><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:Arial,'Helvetica Neue',Helvetica,sans-serif;line-height:19.5px">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.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:Arial,'Helvetica Neue',Helvetica,sans-serif;line-height:19.5px">The module is almost finished, i retrieve data from a API and enter them in the input fields using JQuery.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:Arial,'Helvetica Neue',Helvetica,sans-serif;line-height:19.5px">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.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:Arial,'Helvetica Neue',Helvetica,sans-serif;line-height:19.5px">Only i can't seem to figure out how to create a custom field for the Accounts module from within my module.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:Arial,'Helvetica Neue',Helvetica,sans-serif;line-height:19.5px">I googled around and watched some posts on stackoverflow.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:Arial,'Helvetica Neue',Helvetica,sans-serif;line-height:19.5px">I came up with the following part of code, but this doesn't seem to work.</p><pre style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit">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);
}
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:Arial,'Helvetica Neue',Helvetica,sans-serif;line-height:19.5px">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)</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:Arial,'Helvetica Neue',Helvetica,sans-serif;line-height:19.5px">vtlibhandler:</p><pre style="margin-top:0px;padding:5px;border:0px;font-size:13px;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;word-wrap:normal;background-color:rgb(238,238,238)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit">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.
    }
}
</code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:Arial,'Helvetica Neue',Helvetica,sans-serif;line-height:19.5px">Hopefully someone can give me a push in the right direction.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:Arial,'Helvetica Neue',Helvetica,sans-serif;line-height:19.5px">Thanks in advance :)</p></div>