Cannot Download Import Template

Help,

We added custom relate fields to the leads module using vardefs, and these fields are stored in the cstm table. However, when we tried to download the import template, we encountered an error message that says "Database failure. Please refer to sugarcrm.log for details."

Upon checking the logs, we discovered that SugarCRM is fetching the custom relate fields we created from the core table instead of the cstm table, which is causing the error.

We're currently investigating why SugarCRM is not referencing the correct table and exploring possible solutions to address this issue. If you have any insights or suggestions, we would appreciate your input.

We found on fix but it creates another problem. We added the the "custom_module" in the vardef of the relate field the input element becomes unacceptable some becomes text fields.

Thank you.

  • Hi ,

    if you created your fields through vardefs, Sugar is expecting those fields to be in the core table and not the _cstm (dedicated to fields created from the studio and declared in fields_meta_data table.

    I supposed that, if you launch a quick repair, Sugar will propose a SQL query to align your vardef definition with the core table (so an alter table order to create the missing fields). This should solve your problem (and you will also need to delete the fields you created on the cstm table).

    Other option : change your vardef definition to fields_meta_data definition.

    Fred

  • How do you change the vardef definition. Sorry I'm Still new to this.

  • I suppose that you create a vardef file that contains the name, field type etc.

    I you try to create a field from the studio (same type that the one you created from code), you will see that Sugar will create a new entry in the fields_meta_data table and maybe a sugarfield_xxxx.php file in the custom folder with additionnal parameter.

    So the ID, if you want to keep the fields in the _cstm class is

    * to remove the custom vardef file

    * to create the field from the studio OR manually to create the corresponding line in the DB

    If you want more help, maybe you can share here your vardef.

  • Custom fields should be able to be defined through the Extension vardefs. The important parameter to include in this scenario is to set 'source' to 'custom_fields'. More information on proper ways to define custom fields outside of Studio are documented here:

    support.sugarcrm.com/.../

  • But wouldn't that remove the previous field in the table. I can't really remove the previous field as it already contains data.   

    Here a sample of the vardef created. I added the custom_module attribute and the Download import Template worked. but i created another problem the field became text field rather than a lookup field and i can't save the data added to them.

    <?php

    $dictionary['Lead']['fields']['client_contact_id_1_c'] = array(
    'required' => false,
    'readonly' => false,
    'name' => 'client_contact_id_1_c',
    'vname' => 'LBL_CLIENT_CONTACT_ID_1',
    'type' => 'id',
    'massupdate' => false,
    'hidemassupdate' => false,
    'no_default' => false,
    'comments' => '',
    'help' => '',
    'importable' => 'true',
    'duplicate_merge' => 'enabled',
    'duplicate_merge_dom_value' => 1,
    'audited' => true,
    'reportable' => false,
    'unified_search' => false,
    'merge_filter' => 'disabled',
    'pii' => false,
    'calculated' => false,
    'len' => 36,
    'size' => '20',
    'module' => 'Leads',
    'source' => 'custom_fields',
    );

    $dictionary['Lead']['fields']['client_contact_1_c'] = array(
    'required' => false,
    'readonly' => false,
    'source' => 'non-db',
    'name' => 'client_contact_1_c',
    'vname' => 'LBL_CLIENT_CONTACT_1',
    'type' => 'relate',
    'massupdate' => true,
    'hidemassupdate' => false,
    'no_default' => false,
    'comments' => '',
    'help' => '',
    'importable' => 'true',
    'duplicate_merge' => 'enabled',
    'duplicate_merge_dom_value' => '1',
    'audited' => true,
    'reportable' => true,
    'unified_search' => false,
    'merge_filter' => 'disabled',
    'pii' => false,
    'calculated' => false,
    'len' => 255,
    'size' => '20',
    'id_name' => 'client_contact_id_1_c',
    'ext2' => 'Contacts',
    'module' => 'Contacts',
    'rname' => 'name',
    'quicksearch' => 'enabled',
    'studio' => 'visible',
    'populate_list' => array(
    'email1' => 'client_contact_1_email_c'
    ),
    'custom_module' => 'Contacts'
    );
  • I manage to create a work around but i don't know if this is safe since i would be overriding the core data, and i don't know how to extend this to custom here's how i did it, your input will be appreciated

    I added a custom attribute in the vardef called "source_cstm"


    $dictionary['Lead']['fields']['client_contact_1_c'] = array(
    'required' => false,
    'readonly' => false,
    'source' => 'non-db',
    'name' => 'client_contact_1_c',
    'vname' => 'LBL_CLIENT_CONTACT_1',
    'type' => 'relate',
    'massupdate' => true,
    'hidemassupdate' => false,
    'no_default' => false,
    'comments' => '',
    'help' => '',
    'importable' => 'true',
    'duplicate_merge' => 'enabled',
    'duplicate_merge_dom_value' => '1',
    'audited' => true,
    'reportable' => true,
    'unified_search' => false,
    'merge_filter' => 'disabled',
    'pii' => false,
    'calculated' => false,
    'len' => 255,
    'size' => '20',
    'id_name' => 'client_contact_id_1_c',
    'ext2' => 'Contacts',
    'module' => 'Contacts',
    'rname' => 'name',
    'quicksearch' => 'enabled',
    'studio' => 'visible',
    'populate_list' => array(
    'email1' => 'client_contact_1_email_c'
    ),
    'source_cstm' => 'Contacts'
    );

    And in the "modules/DynamicFields/DynamicField.php" I added the "source_cstm"  in the logic

    And it worked. How can i make this upgrade safe by extending. I tried it but its not working.

    Here's the code I made.

    Am I extending it right? Sorry for the inconvenience, Thank for your patience Slight smile