Button Field - How to embed the "definition" in a vardef file instead of partial DB storage

Hi Guys,

I have a quick question : do you know how to store in a vardef file the FULL definition of a button field (instead of the current storage when created from the studio with partial storage in DB table) ?

The purpose of this request is to easily deploy custom buttons for our customers and also be able to track the code with GIT.

Many thanks,

Fred

  • Hi,

    we figured how to do it, so if some of you are interested, contact me.

    Regards

    Fred

  •  I am interested Slight smile.

    SugarCRM | Principal Developer Advocate

  • Hi  ,

    today we do this that way

    1 ) create a sugarfield_the_name_of_my_button.php in

    custom/Extension/modules/<MODULE_NAME>/Ext/Vardefs

    2) include a basic definition for the field

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    <?php
    // this file was created by dotBase the ...
    $dictionary['MODULE_NAME']['fields']['the_name_of_my_button']['name']='the_name_of_my_button';
    $dictionary['MODULE_NAME']['fields']['the_name_of_my_button']['vname']='LBL_THE_NAME_OF_MY_BUTTON';
    $dictionary['MODULE_NAME']['fields']['the_name_of_my_button']['type']='actionbutton';
    $dictionary['MODULE_NAME']['fields']['the_name_of_my_button']['options']='';
    $dictionary['MODULE_NAME']['fields']['the_name_of_my_button']['dbType']='text';
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    3) launch a quick repair and run the query to align DB and code

    4) finish the button configuration from studio, so all the settings will be stored inside the sugarfield_xxx instead of fields_metadata

    OF COURSE, we are aware that this field is not seen as a custom field and so created in the main table.

    But this is a most convenient way for us to track code customisation / versionning using GIT, even more with mutliple environnement (DEV, STAGING, PROD etc.).

    Hope it helps,

    Fred

  •  interesting solution, thanks for sharing.. 

    SugarCRM | Principal Developer Advocate

  • If you create such a button in studio you get the full vardef description in cache/modules/MODULE/MODULEvardefs.php. As an example I created  button in Accounts which results in the following vardef code:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    'button1_c' =>
    array (
    'labelValue' => 'Button1',
    'required' => false,
    'readonly' => true,
    'source' => 'non-db',
    'name' => 'button1_c',
    'vname' => 'LBL_BUTTON1',
    'type' => 'actionbutton',
    'massupdate' => false,
    'hidemassupdate' => false,
    'no_default' => false,
    'comments' => 'Comment for Button 1',
    'help' => 'Help for Button 1',
    'importable' => 'true',
    'duplicate_merge' => 'enabled',
    'duplicate_merge_dom_value' => 1,
    'audited' => false,
    'reportable' => true,
    'unified_search' => false,
    'merge_filter' => 'disabled',
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Most complicated part is the options field which is generated by the QR&R from the DB definition.

    In a development environment you have access to the cache folder and you can extract this definition form the vardef file to include it in custom/Extension/modules/MODULEs/Ext/Vardefs/ folder and by this in GIT.