sardoj / VTModuleDesigner

Module Designer for Vtiger 6
Other
69 stars 61 forks source link

Create a new module and add a 'related to'- field in existing module to the new created module #6

Open samhast opened 10 years ago

samhast commented 10 years ago

I created the module 'Dealers'. That works perfect! Now I edit the existing 'Potential' module and added a related_to field (related to Dealers module)

When I create new potential and click on save, I receive an error message: {"success":false,"error":{"code":"Record you are trying to access is not found","message":"Record you are trying to access is not found"}}

sardoj commented 10 years ago

Hello, The problem is due to Vtlib which is not complete. I've just added a patch in VTModuleDesigner. Have a look.

samhast commented 10 years ago

How do I have to install the patch?

sardoj commented 10 years ago

Replace these files :

By files included in the path archive

samhast commented 10 years ago

Did that. But still the same problem: {"success":false,"error":{"code":"Record you are trying to access is not found","message":"Record you are trying to access is not found"}}

sardoj commented 10 years ago

Ok, understood.

VTModuleDesigner does not work very well with modules having multiple tables. I will improve this later. But I think "Potential" use several tables. For the moment, create manually the column related to your new field, in the good table.

samhast commented 10 years ago

Ok, I checked in the vtiger_potential table. There I added the column, but always the same error. I wait until it's fixed in your ModuleCreator.

The creator added vtiger_potentials with following fields: potentialsid dealer_name

apcloic commented 10 years ago

Hello Samhast, if it's the same way as with vtiger 5.4, you have to add the relation in vtiger_relatedlists table You will find your custom module ID in the vtiger_entityname table 'hope it helps

samhast commented 10 years ago

This is already the case: relation_id = 154 tabid = 49 related_tabid = 2 name = get_realted_list sequence = 1 label = Opportunities Actions = ADD

sardoj commented 10 years ago

Originally VTModuleDesigner's goal was to create custom modules, not to edit existant core modules. But I see a lot of you want this functionality. So I will try to improve it.

apcloic commented 10 years ago

Hi Samhast, here is the working code I use to add a related to custom module field in existing module. Example to add related field MyModule to Contacts Module : Create a php file at the root of your vtiger installation, edit the following code with your own values and load the page.

<?php // Turn on debugging level $Vtiger_Utils_Log = true; // Include necessary classes include_once('vtlib/Vtiger/Module.php'); include_once('vtlib/Vtiger/Menu.php'); / Relationship 1:m (1 MyModule, x Contacts) / // Define instances $contacts = Vtiger_Module::getInstance('Contacts'); $mymodule = Vtiger_Module::getInstance('MyModule'); $block = Vtiger_Block::getInstance('LBL_CONTACT_INFORMATION', $contacts);

// Add field $field = new Vtiger_Field(); $field->name = 'MyModule'; $field->table = 'vtiger_contactdetails'; $field->column = 'mymodule_id'; $field->columntype = 'VARCHAR(255)'; $field->uitype = 10; $field->typeofdata = 'V~O'; $block->addField($field); $field->setRelatedModules(Array('MyModule')); ?>

I've also found a way to manually add my custom module in related list view of an existing module : 1st you need to add the relation between your custom module and the existing one in vtiger_relatedlist table Then, you have to edit the file MyModule.php and populate the arrays for var $list_fields, var $list_fields_name, var $search_fields and var $search_fields_name Something like this :

/**
 * Mandatory for Listing (Related listview)
 */
var $list_fields = Array (
    'My Value Name'=>Array('valuename'=>'name_value'),
    'My Custom ID'=>Array('mycustomid'=>'id_custom'),
);
var $list_fields_name = Array (
           'My Value Name'=>'name_value',
           'My Custom ID'=>'id_custom',
);

// Make the field link to detail view
var $list_link_field = 'id_custom';

// For Popup listview and UI type support
var $search_fields = Array(
    'My Value Name'=>Array('valuename'=>'name_value'),
    'My Custom ID'=>Array('mycustomid'=>'id_custom'),

);
var $search_fields_name = Array (
           'My Value Name'=>'name_value',
           'My Custom ID'=>'id_custom',
);

'hope it helps. Regards,

waran70 commented 10 years ago

Hi apcloic

how about documents <> custom module? I feel like use ui 10 in documents to tie it to the module which in my has higher level system. Is this code working with documents too? The only thing I wanna change is that the tie should be released therefore UI 10 shouldn't be required but optional.. how do you think?

apcloic commented 10 years ago

Hi Waran70, I think it should be working with documents module too. When you add your UI 10 with Module Designer, you can choose if it's mandatory field or not, so I think there should be no problem.

waran70 commented 10 years ago

Will try, my production app got thousands of docs and dont wanna mess it. So you suggest to add UI type 10 using ModuleDesigner and than fire code you mentioned above (after changes of course)?

waran70 commented 10 years ago

Record you are trying to access is not found. Go back Seems not working O.o Any idea?

sardoj commented 10 years ago

Hello,

You must create, one and only one field as an identifier. Then you must install the patch given with Module Designer to improve Vtiger's import/export/update system. With it, Vtiger will be able to automatically create new columns in the datable table.

Direct link : https://github.com/sardoj/VTModuleDesigner/tree/master/patch

waran70 commented 10 years ago

This helps so I can open document but existing documents gone somwhere and when trying add new one crm wanna me download index.php.. are you able to reproduce adding UI 10 to documents so this module will be tied to other custom module? I finding it very useful in many scenarios so it can bring advantages for users/developers

Thanks in advance Ian

On Thu, Mar 6, 2014 at 2:43 PM, Jonathan notifications@github.com wrote:

Hello,

You must create, one and only one field as an identifier. Then you must install the patch given with Module Designer to improve Vtiger's import/export/update system. With it, Vtiger will be able to automatically create new columns in the datable table.

Direct link : https://github.com/sardoj/VTModuleDesigner/tree/master/patch

Reply to this email directly or view it on GitHubhttps://github.com/sardoj/VTModuleDesigner/issues/6#issuecomment-36831921 .

bwanika commented 10 years ago

How do I edit an existing Module? I created a new Module and I want to add it as a related module to the Contacts Module.

geofmureithi-zz commented 10 years ago

I am also experiencing the same problem, what is the fix?