Default value in record creation field

I explain the situation and what I would like to do:
I have a custom module in which there are some data and a subpanel in particular, at the time of creating a record of this subpanel, I would like a data that is in the detail of the module to be assigned by default (not editable) to a field of the subpanel, so that when I save the record it also saves that field. This just described is the procedure for the quick creation of the record, but the same thing must happen for the creation of the complete form.
What I managed to do is go to:


and add:

$dictionary["<MODULE>"]["fields"]["<field>"] = array (
  'name' => '<field>_ida',
  'source' => 'non-db',
  'vname' => 'LBL_ID',
  'save' => true,
  'id_name' => '<field>_ida',

getting the filling of the desired field (via this line ‘name’ => ‘_ida’), but when saving, this field is not saved, as if its value were not filled.

I also tried another method, going to edit this file:


and inserting in the field in question, this line:

'customCode' => '{$fields.<field>_ida.value}',

here too it works as I expect, but if I save the record, that field is not stored.

Anyone have any idea how to fix? Something is missing? Is there a different procedure to perform?

If you say the field is non-db, it won’t go on the database.

Just make it a normal field with a set type. Make sure you go in QR&R and scroll down to make DB changes.

1 Like

Hi pgr,
I followed your suggestions:
I removed the line

'source' => 'non-db',

and I set the type

'type' => 'int',

but nothing, that field is not stored

I’m not sure about all the details, but why don’t you just create the field from Studio as usual? Then you can work on the rest of your requirements (read-only + filled with default value) after the database link is working correctly.

The field I created by studio, but I need to fill it dynamically, so if I create a record it must also populate that field with that data coming from the detail of the module where that subpanel is located.
From Studio, I can’t do what I just described.
But if there are other ideas besides the one I have outlined above, that’s fine.

Actually my PowerFields SuiteCRM add-on would be perfect for this :smiley:

I’d say you could try a Workflow or a Logic Hook. This is not a matter of field definition (Studio, database, etc), it’s a matter of adding a bit of code.

1 Like

It is not my project and I cannot add new modules.
The weird thing is that if I fill that field manually, after the correct value appears inside, the field is stored, so it’s like what I actually see is the id or the name, but not the value. I also tried to insert a new line:
'default' =>
in this case, instead of storing NULL, it stores 0.

Have you tried a Workflow?

Not, being a dynamic field, I wouldn’t know how to set the value


You can do this with a controller in your custom module.

Here is an example of what we have done when creating a quote from an opportunity:


class CustomAOS_QuotesController extends AOS_QuotesController
    public function action_editview()
        if (isset($_REQUEST['opportunity_id'])) {
        	$opportunity=BeanFactory::getBean('Opportunities', $_REQUEST['opportunity_id']);

            $this->bean->number_months_c = $opportunity->number_months_c;


For your custom module, the class should extend SugarController and you would need to replace
$this->view = ‘edit’;
$GLOBALS[‘view’] = $this->view;

1 Like

Thanks pgr and blqt, I solved it very simply:
in quickvardefs.php I added this line to the field of my interest

'customCode' => '<input value = "{$ fields. <field_value> .value}" id = "id" name = "id" readonly>',