0

I followed all the steps mentioned on create custom module in vtiger 6 to create custom module but I am getting the error Module already present - choose a different name

Please advice.

Community
  • 1
  • 1
  • 1
    Possible duplicate of [create custom module in vtiger 6](http://stackoverflow.com/questions/24301631/create-custom-module-in-vtiger-6) – Morten Bergfall Apr 11 '16 at 14:26

1 Answers1

0

As your are using vtiger 6.4 , there are lot of difference between vTiger 6 and vtiger6.4.

Try with the below script as I am using same for new module creation. Use new module name. And change the UI Types and field labels as per your requirement.

<?php

    $Vtiger_Utils_Log = true;
    include_once('vtlib/Vtiger/Menu.php');
    include_once('vtlib/Vtiger/Module.php');


    $module = new Vtiger_Module();
    $module->name = 'Your_MODULE_NAME';
    $module->parent = 'Tools';
    $module->save();

    $module->initTables();
    $module->initWebservice();

    $block = new Vtiger_Block();
    $block->label = 'LBL_INFORMATION_DETAIL';
    $module->addBlock($block); //to create a new block

    $field1  = new Vtiger_Field();
    $field1->name = 'browse';
    $field1->table=$module->basetable;
    $field1->label= 'Upload Csv';
    $field1->column = 'browse';
    $field1->columntype = 'VARCHAR(255)';
    $field1->uitype= 28;
    $field1->typeofdata = 'V~O';
    $block->addField($field1);  

    $field2  = new Vtiger_Field();
    $field2->name = 'fieldid';
    $field2->table=$module->basetable;
    $field2->label= 'Record ID';
    $field2->uitype= 4;
    $field2->column = 'fieldid';
    $field2->columntype = 'VARCHAR(255)';
    $field2->typeofdata = 'V~M';
    $block->addField($field2);  
    $module->setEntityIdentifier($field2);      

    $field3  = new Vtiger_Field();
    $field3->name = 'age';
    $field3->table=$module->basetable;
    $field3->label= 'Age';
    $field3->uitype= 1;
    $field3->column = 'age';
    $field3->columntype = 'VARCHAR(100)';
    $field3->typeofdata = 'V~O';
    $block->addField($field3);  

    $field4  = new Vtiger_Field();
    $field4->name = 'statusrecord';
    $field4->table=$module->basetable;
    $field4->label= 'Status';
    $field4->uitype= 15;
    $field4->column = 'statusrecord';
    $field4->columntype = 'VARCHAR(255)';
    $field4->setPicklistValues( Array('new','closed','closedwithfailure','inprogress'));
    $field4->typeofdata = 'V~M';
    $block->addField($field4);      

    // Recommended common fields every Entity module should have (linked to core table) 
    $field5 = new Vtiger_Field();
    $field5->name = 'assigned_user_id';
    $field5->label = 'Assigned To';
    $field5->table = 'Vtiger_crmentity';
    $field5->column = 'smownerid';
    $field5->uitype = 53;
    $field5->typeofdata = 'V~M';
    $block->addField($field5);

    $field6 = new Vtiger_Field();
    $field6->name = 'CreatedTime';
    $field6->label= 'Created Time';
    $field6->table = 'Vtiger_crmentity';
    $field6->column = 'createdtime';
    $field6->uitype = 70;
    $field6->typeofdata = 'T~O';
    $field6->displaytype= 2;
    $block->addField($field6);

    $field7 = new Vtiger_Field();
    $field7->name = 'ModifiedTime';
    $field7->label= 'Modified Time';
    $field7->table = 'Vtiger_crmentity';
    $field7->column = 'modifiedtime';
    $field7->uitype = 70;
    $field7->typeofdata = 'T~O';
    $field7->displaytype= 2;
    $block->addField($field7);   

    // Filter Setup    
    $filter1 = new Vtiger_Filter();
    $filter1->name = 'All';
    $filter1->isdefault = true;
    $module->addFilter($filter1);
    // Add fields to the filter create 

    $filter1->addField($field7, 2);
    $filter1->addField($field3, 3);
    $filter1->addField($field4, 5);

    /** Set sharing access of this module */
    $module->setDefaultSharing(); 
    /** Enable and Disable available tools */
    $module->enableTools(Array('Import', 'Export'));
    $module->disableTools('Merge');         
?>

You can also refer Entity-Module-Documentation

Sachin I
  • 1,500
  • 3
  • 10
  • 29
  • Thanks for the above script. I created the module successfully and when I went to the module and added a test record and hit the save button I got an error on a blank page that - "{"success":false,"error":{"code":"Record you are trying to access is not found","message":"Record you are trying to access is not found"}}" please advice. – onekadoplant Apr 11 '16 at 18:32
  • Remove the filter and try... You have to modify the script as per your need. Use the parent module which is available in your crm. – Sachin I Apr 12 '16 at 06:18
  • how to remove the filter? – onekadoplant Apr 12 '16 at 06:33
  • Remove the filter code from script.. just below of //Filter Setup and try with giving new module name – Sachin I Apr 12 '16 at 06:47
  • in that case then I need to delete this module..how can I delete it? Can I use the below script to delet the module? delete(); echo "Module Deleted!"; } else { echo "Module was not found and could not be deleted!"; } ?> – onekadoplant Apr 12 '16 at 06:56
  • But if I delete the filter code then I wont be able to use filter functionality for the custom module aand I want to use the filter function. Please advice the best solution. Thanks – onekadoplant Apr 12 '16 at 09:21
  • can you please confirm if the above delete module script is correct so that I can delete this module and create again everything. Please help. Thanks. – onekadoplant Apr 12 '16 at 10:15
  • I deleted the module and then once again recreated that module in crm and this time I deleted //Filter Setup too, but still when I save a record I get the error {"success":false,"error":{"code":"Record you are trying to access is not found","message":"Record you are trying to access is not found"}} please help me. Thanks – onekadoplant Apr 12 '16 at 11:42
  • I created the module properly but now wheneven I add any custom field I get the error message "Record you are trying to access is not found" please help me. – onekadoplant Apr 14 '16 at 10:37