Add file field programmatically over an existing module

Hi.
I need to add a file field in an existing custom module, so i tried made some custom code in flie ‘/suitecrm/custom/Extension/modules/mymodule/Ext/Vardefs/mymodulefile.php’:


$dictionary["mymodule"]["fields"]["file_mime_type"] = array (
  'name' => 'file_mime_type',
  'vname' => 'LBL_FILE_MIME_TYPE',
  'type' => 'varchar',
  'len' => '100',
  'importable' => false,
);
$dictionary["mymodule"]["fields"]["file_url"] = array (
  'name'=>'file_url',
  'vname' => 'LBL_FILE_URL',
  'type'=>'function',
  'function_require' => 'include/upload_file.php',
  'function_class'=>'UploadFile',
  'function_name'=>'get_url',
  'function_params'=> array(
	0 => 'filename',
        1 => 'id',),
  'source'=>'function',
  'reportable'=>false,
  'importable' => false,
);
$dictionary["mymodule"]["fields"]["filename"] = array(
  'name' => 'filename',
  'vname' => 'LBL_FILENAME',
  'type' => 'file',
  'dbType' => 'varchar',
  'len' => '255',
  'reportable'=>true,
  'importable' => false,
);

I can see now the file field in studio and can add it to the views.
The problem is that in edit view i can browse and add the file but in detail view i cannot see the file link to open it, it seems it doesn upload after all

1 Like

Have you fix it? I’m looking for the same feature.
Thanks

Hi LucioF.

Yeah, i fixed this, sorry i didn’t remember exactly how i did.

What i can tell you is that i checked a function that upload file from another module and added the code i was missing, (also this have a javascript code), it wasnt hard, just followed that code.

I hope this helped you.

The Detail View Defs might need some tweaks or arguments for showing the Files? Anyhow apart from having many files FIELDS i found MultiUpload Files plugin on store which offers to upload many files using one single Field. Need to try it out as the features listed are appealing.