How can I make name field read-only and automatically get its name from other fields?

I am trying to upgrade this module.  I need to have the name field for the non-BWC module to be read-only and automatically get it name based on other fields.

Thank you,

Amy

  • Hi you can do it converting the field to calculated from studio or you can add "readonly" = true, in the record view field. The route must to be: custom/modules/<custom_module_name/clients/base/views/record/record.php

    Regards.

  • If you convert your field from the studio to "calculated field", you will add a sugar logic formula in your field but you must be carefull with the value because every time you do an update the calculated field will be updated, so, you can validate with a ifElse sugar logic formula.

    If you edit the record view file, this will not let you change the field value from user interface, but the readonly attribute will not be authomatical.
    here an example:

    I hope this be useful.

    Kind Regards.

  • Hi ,

    when you add a formula to a text field like name it will be set to some special kind of read-only. You see that in the sugarfield_*.php file of the extension framework. There is an entry like (e.g. for Bugs module):

    $dictionary['Bug']['fields']['name']['enforced']=true;

    That means the value is always calculated by SugarLogic.

    If you change that value to

    $dictionary['Bug']['fields']['name']['enforced']=false;

    the value is calculated by SugarLogic when the field is empty and it remains editable. So you can change it manually and the value remains unchanged even when you trigger a recalculation.

    To make sure this value is not overwritten by some other customization you can write that single line of php code in a file e.g. for Bugs custom/Extension/modules/Ext(Vardefs/_override_name_field.php which will always overwrite the definitions from sugarfield _name.php during QR&R when it starts with "_override". For the name filed of the Bugs module the file would look like this:

    <?php
    // Set name field editable:
    $dictionary['Bug']['fields']['name']['enforced']=false;
    

    Harald Kuske
    Principal Solution Architect – Professional Services, EMEA
    hkuske@sugarcrm.com
    SugarCRM Deutschland GmbH