Auto populate fields when i select quotation

I'm fighting against this issue since a couple of weeks and I can't figure out a way to do that.

Because i am new to sugarcrm and development

I have created a custom module COF where i want to select the quotation then auto populate the fields(all fields from quotation) to COF. so how can i get the values easily from one module to another module.

1. Can we do this based on JS because i want to edit any field then i can edit before save.

2. is it possible with custom logic hook. before save the document.

Francesca Shiekh hatsVignesh V

 I really need help, as soon as possible.

Thank you

  • Hi Ash,

    You can use 'populate_list' property in vardef file of a quote relate field to auto populate the COF module fields based on related quote.

    For eg: if your vardef file is custom/Extension/modules/<COF_Module>/Ext/Vardefs/<cof_quote_file.php>

    $dictionary['<COF_Module>']['fields']['<quote_relate_name>']['populate_list']['name']='<field_in_cof_module>'; //populate quote name to <field_in_cof_module>
    $dictionary['<COF_Module>']['fields']['<quote_relate_name>']['populate_list']['description']='<field_in_cof_module>'; //populate quote description to <field_in_cof_module>

    Similarly, you can use this property to populate as many fields as you want from the related quote module.

    Let us know if this helps.

    Regards.

  • hats

    Thanks for Reply,

    In my vardef file multiple files are there like relationship fields and text fields 

    so should i write in relationship file(cof_customerorderform_quotes_1_COF_CustomerOrderForm) or billing address,billing city individusl files

  • I have added these lines in relate field [created from studio to select quotation]. but fields are not auto populating

    custom/Extension/modules/COF_CustomerOrderForm/Ext/Vardefs/sugarfield_quotation_c.php

    <?php
    $dictionary['COF_CustomerOrderForm']['fields']['quotation_c']['labelValue']='Quotation';
    $dictionary['COF_CustomerOrderForm']['fields']['quotation_c']['dependency']='';
    $dictionary['COF_CustomerOrderForm']['fields']['quotation_c']['populate_list']['cof_customername_c']='billing_account_name';
    $dictionary['COF_CustomerOrderForm']['fields']['quotation_c']['populate_list']['contactname_c']='billing_contact_name';
    $dictionary['COF_CustomerOrderForm']['fields']['quotation_c']['populate_list']['billingaddress_c']='billing_address_street';
    $dictionary['COF_CustomerOrderForm']['fields']['quotation_c']['populate_list']['billingstate_c']='billing_address_state';
    $dictionary['COF_CustomerOrderForm']['fields']['quotation_c']['populate_list']['billingcountry_c']='billing_address_country';

    ?>

  • Hi Ash,

    Are you sure that 'quotation_c' field is a quotes relate field?

    From your screenshot above, cof_customerorderform_quotes_1_COF_CustomerOrderForm.php looks like the correct field. Please use populate_list property for the relate type field in that file.

    Also, make sure that the field on the left hand side is the field from quotes module and on the right hand side fields from your custom COF module.

    Regards.

  • hats still i am in confusion help me to solve this

    This is a Relationship file

    In cof_customerorderform_quotes_1_COF_CustomerOrderForm.php

    <?php
    $dictionary["COF_CustomerOrderForm"]["fields"]["cof_customerorderform_quotes_1"] = array (
    'name' => 'cof_customerorderform_quotes_1',
    'type' => 'link',
    'relationship' => 'cof_customerorderform_quotes_1',
    'source' => 'non-db',
    'module' => 'Quotes',
    'bean_name' => 'Quote',
    'vname' => 'LBL_COF_CUSTOMERORDERFORM_QUOTES_1_FROM_QUOTES_TITLE',
    'id_name' => 'cof_customerorderform_quotes_1quotes_idb',
    );

    This is a relate field Created In record view from studio

    <?php

    $dictionary['COF_CustomerOrderForm']['fields']['quotation_c']['labelValue']='Quotation';
    $dictionary['COF_CustomerOrderForm']['fields']['quotation_c']['dependency']=' ';

    ?>

    In this file i have tried with 

    $dictionary['<COF_Module>']['fields']['<quote_relate_name>']['populate_list']['name']='<field_in_cof_module>'; //populate quote name to <field_in_cof_module>
    $dictionary['<COF_Module>']['fields']['<quote_relate_name>']['populate_list']['description']='<field_in_cof_module>'; //populate quote description to <field_in_cof_module>

    but its not working