Remove confirmation popup when using relate field to populate other fields?

Is there some way of removing confirmation popups when using an added relate field to populate other fields in Opportunities?

We are using relate fields to bring in default values from a custom module. However, since the use-case contains more than one relate field, we would need to make the user experience more fluent by removing the confirmation popup which comes when the relate field item is selected.

(If the confirmation box only appeared for fields that the user would have entered data already, it would be ok, but it seems to appear even if the fields to be populated have not been entered any data yet.)

The development is for an on-demand Sugar Professional (currently 7.6.1)

Based on HOWTO: Using a relate field to populate a custom field « Sugar Developer Portal – SugarCRM

Parents
  • Hi Juho,

    $dictionary[Opportunity]['fields']['{YOUR FIELD NAME}']['auto_populate'] = true;

    Add the above line to either

    ~custom/Extension/modules/Opportunites/Ext/Vardefs/sugarfield_{name_of_your_field}.php

    or

    create a new php file with any random name inside ~custom/Extension/modules/Opportunites/Ext/Vardefs/{random_filename}.php

     

    Hope it helps!

    -Shijin Krishna

  • Thank you for your answer Shijin. Unfortunately, that did not seem to be enough. Here's the vardef in it's current form (with some translations to make it more client-anonymized and english-friendly):

    $dictionary['Opportunity']['fields']['item_1'] = array (

        'name' => 'item_1',

        'vname' => 'LBL_ITEM',

        'type' => 'relate',

        'source' => 'non-db',

        'audited' => true,

        'reportable' => true,

        'unified_search' => false,

        'importable' => 'true',

        'required' => false,

        'id_name' => '<our_custom_module>_id_1',

        'ext2' => '<our_custom_module>',

        'module' => '<our_custom_module>',

        'rname' => 'name',

        'quicksearch' => 'enabled',

        'studio' => 'visible',

        'populate_list' => array(

                    'price' => 'unit_price_1',

                    'code_required' => 'code_required_1',

                ),

        'auto-populate' => true,

    );

    I also tried adding it to the target fields, just in case, but that didn't help either. And naturally I ran Quick Repair and Rebuild after making the updates. The populate part works, but there is still the confirmation pop-up warning which we wish to get rid of.

  • Hi Juho,

    Yes, you have to run Quick Repair and Rebuild, which I forgot to mention. Just try selectin a new value in related field after clearing your browser cache from beginning.

    It should work, because if see the js controller for relate field you will find something like below.

    // if this.def.auto_populate is true set new data and doesn't show alert message

            if (!_.isUndefined(this.def.auto_populate) && this.def.auto_populate == true) {

                // if we have a currency_id, set it first to trigger the currency conversion before setting

                // the values to the model, this prevents double conversion from happening

                if (!_.isUndefined(newData.currency_id)) {

                    this.model.set({currency_id: newData.currency_id});

                    delete newData.currency_id;

                }

                this.model.set(newData);

                return;

            }

    I am not sure why it didn't work for you. Please navigate to cache/modules/Opportunities/Opportunitiesvardefs.php

    and search for your custom field 'item_1'. And check whether the auto_populate property has been added or not.

    Please let me know after that.

    Thanks!

    -Shijin Krishna

  • Duh. Once I started adding debug code to the js file I found out I had a shift-fault/typo in the vardef, auto-populate and auto_populate are so close that one does not easily spot it...

    Now it seems to work. Thank you!

Reply Children
No Data