Auto populate note / task name with Opportunity name

When creating a note / task from a subpanel in Opportunities, is it possible to pre-populate the name of note / task with the name of the opportunity? This needs to work on mobile as well, so I can't do it in javascript (I don't think at least). If I make the name field a calculated field to be a related($opportunities, "name"), it works after the save. I need the user to be able to see it and change it if necessary. So essentially I need a way to type in the name for the user. Is this possible? I've spent a while trying a few things, nothing has been successful. 

Parents
  • Hi Ryan Horton 

    It is possible to make it work even on mobile.

    You have to:

    • create the field opp_name in Tasks and Notes
    • Configure the attribute populate_list in the field definition of tasks and notes at module Opportunities (take a look at the field contacts in the vardefs of Opportunities module)
    • Define a SugarLogic formula for calculating the name of Task and Note accordingly

    Regards

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • I've taken these steps and the web works, but the mobile app does not. Does something else need to be done for this to work on mobile? 

    The field I created was parent_name. My populate list has 'name' => 'parent_name_c'. 'name' in Task / Notes has a calculation of simply $parent_name_c. This all work as expected in web.

    When on mobile a few odd things. parent_name_c isn't being populated in the edit view.

    When I added parent_name_c to the edit layout and went to deploy, I got the following message:

    Is there something I am missing?

  • Something I forgot to mention:

    You must add the field parent_name_c in the layout of mobile. Make it readonly at the begining to make sure it is properly populated and then make it not visible.

    Regards

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • After setting the 'parent_name_c' field to readonly and adding it to the layout, it still isn't populating in mobile app or mobile web. I can't click in the field on the mobile so it seems that readonly works. If it matters, I am on 8.0.2.

  • Can you share the content of vardefs for tasks and notes link fields in Opportunities module and formula for field name on both Tasks and Notes modules?

    Regards

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • custom/Extension/modules/Opportunities/Ext/Vardefs/populate_names_task_notes.php

    <?php

    $dictionary['Opportunity']['fields']['tasks']['populate_list'] = array('name' => 'parents_name_c');
    $dictionary['Opportunity']['fields']['notes']['populate_list'] = array('name' => 'parents_name_c');

    custom/Extension/modules/Notes/Ext/Vardefs/sugarfield_name.php

    <?php


    $dictionary['Note']['fields']['name']['audited'] = false;
    $dictionary['Note']['fields']['name']['massupdate'] = false;
    $dictionary['Note']['fields']['name']['comments'] = 'Name of the note';
    $dictionary['Note']['fields']['name']['importable'] = 'false';
    $dictionary['Note']['fields']['name']['duplicate_merge'] = 'disabled';
    $dictionary['Note']['fields']['name']['duplicate_merge_dom_value'] = 0;
    $dictionary['Note']['fields']['name']['merge_filter'] = 'disabled';
    $dictionary['Note']['fields']['name']['full_text_search'] = array(
    'enabled' => true,
    'boost' => '0.83',
    'searchable' => true,
    );
    $dictionary['Note']['fields']['name']['calculated'] = 'true';
    $dictionary['Note']['fields']['name']['formula'] = '$parents_name_c';
    $dictionary['Note']['fields']['name']['enforced'] = false;

    custom/Extension/modules/Tasks/Ext/Vardefs/sugarfield_name.php

    <?php


    $dictionary['Task']['fields']['name']['audited'] = false;
    $dictionary['Task']['fields']['name']['massupdate'] = false;
    $dictionary['Task']['fields']['name']['importable'] = 'false';
    $dictionary['Task']['fields']['name']['duplicate_merge'] = 'disabled';
    $dictionary['Task']['fields']['name']['duplicate_merge_dom_value'] = 0;
    $dictionary['Task']['fields']['name']['merge_filter'] = 'disabled';
    $dictionary['Task']['fields']['name']['unified_search'] = false;
    $dictionary['Task']['fields']['name']['full_text_search'] = array(
    'enabled' => true,
    'boost' => '1.45',
    'searchable' => true,
    );
    $dictionary['Task']['fields']['name']['calculated'] = 'true';
    $dictionary['Task']['fields']['name']['formula'] = '$parents_name_c';
    $dictionary['Task']['fields']['name']['enforced'] = false;

    custom/modules/Tasks/clients/mobile/views/edit/edit.php

    'fields' =>
       array(
          0 =>
             array(
                'name' => 'parents_name_c',
                'label' => 'LBL_PARENTS_NAME',
                'readonly' => true
             ),

    custom/modules/Notes/clients/mobile/views/edit/edit.php

    'fields' =>
       array(
          0 =>
             array(
                'name' => 'parents_name_c',
                'label' => 'LBL_PARENTS_NAME',
                'readonly' => true,
             ),

    Thanks for your help in this André Lopes

Reply
  • custom/Extension/modules/Opportunities/Ext/Vardefs/populate_names_task_notes.php

    <?php

    $dictionary['Opportunity']['fields']['tasks']['populate_list'] = array('name' => 'parents_name_c');
    $dictionary['Opportunity']['fields']['notes']['populate_list'] = array('name' => 'parents_name_c');

    custom/Extension/modules/Notes/Ext/Vardefs/sugarfield_name.php

    <?php


    $dictionary['Note']['fields']['name']['audited'] = false;
    $dictionary['Note']['fields']['name']['massupdate'] = false;
    $dictionary['Note']['fields']['name']['comments'] = 'Name of the note';
    $dictionary['Note']['fields']['name']['importable'] = 'false';
    $dictionary['Note']['fields']['name']['duplicate_merge'] = 'disabled';
    $dictionary['Note']['fields']['name']['duplicate_merge_dom_value'] = 0;
    $dictionary['Note']['fields']['name']['merge_filter'] = 'disabled';
    $dictionary['Note']['fields']['name']['full_text_search'] = array(
    'enabled' => true,
    'boost' => '0.83',
    'searchable' => true,
    );
    $dictionary['Note']['fields']['name']['calculated'] = 'true';
    $dictionary['Note']['fields']['name']['formula'] = '$parents_name_c';
    $dictionary['Note']['fields']['name']['enforced'] = false;

    custom/Extension/modules/Tasks/Ext/Vardefs/sugarfield_name.php

    <?php


    $dictionary['Task']['fields']['name']['audited'] = false;
    $dictionary['Task']['fields']['name']['massupdate'] = false;
    $dictionary['Task']['fields']['name']['importable'] = 'false';
    $dictionary['Task']['fields']['name']['duplicate_merge'] = 'disabled';
    $dictionary['Task']['fields']['name']['duplicate_merge_dom_value'] = 0;
    $dictionary['Task']['fields']['name']['merge_filter'] = 'disabled';
    $dictionary['Task']['fields']['name']['unified_search'] = false;
    $dictionary['Task']['fields']['name']['full_text_search'] = array(
    'enabled' => true,
    'boost' => '1.45',
    'searchable' => true,
    );
    $dictionary['Task']['fields']['name']['calculated'] = 'true';
    $dictionary['Task']['fields']['name']['formula'] = '$parents_name_c';
    $dictionary['Task']['fields']['name']['enforced'] = false;

    custom/modules/Tasks/clients/mobile/views/edit/edit.php

    'fields' =>
       array(
          0 =>
             array(
                'name' => 'parents_name_c',
                'label' => 'LBL_PARENTS_NAME',
                'readonly' => true
             ),

    custom/modules/Notes/clients/mobile/views/edit/edit.php

    'fields' =>
       array(
          0 =>
             array(
                'name' => 'parents_name_c',
                'label' => 'LBL_PARENTS_NAME',
                'readonly' => true,
             ),

    Thanks for your help in this André Lopes

Children