How can we create upload document fields on lead module in suiteCRM

Hi ,

In lead module how can we create upload document field and dependency drop down (means based on first drop down value second drop drop value should come ).

Thanks
Sandeep

Look at the files of the module Notes as example.

Hi @p.konetskiy,thanks for your valuable reponse ,
Sorry I did not get you ,can we create “choose file” option to upload documents and one more think is ,is it possible to create dependency drop dwon like based on first drop down values the second drop down should show .

could plz help on this two thinks ,this is so helpfull for me .

Thanks
Sandeep

@muralasandeep123

  1. You can do it but it’s doesn’t support in Studio. You can do it if edit files. Are you ready to do it?
  2. You can load 3 new type of fields (include load multi files collection files): Solution for support three new fields types in Studio
  1. You can use Dynamic Dropdown type field in Studio. Look at video: How to Use Dynamic Fields

@p.konetskiy,I am really appriciate you,for your valuable reponse .

How can I do this one ,could you plz help on it ,I am ready to do ,but please exaplain the proccess how can I do,If you have any vide also plz share to me that is so helpfull to me .

Thanks
Sandeep

@muralasandeep123

  1. Create the file custom/Extension/modules/<module_name>/Ext/Vardefs/fileupload.php with the code. (here and next change <module_name> or <object_name> to real names.)
<?php
$dictionary['<object_name>']['fields']['filename']=array(
    'name' => 'filename',
    'vname' => 'LBL_FILENAME',
    'type' => 'varchar',
    'required'=>true,
    'importable' => 'required',
    'len' => '255',
    'studio' => 'false',
);
$dictionary['<object_name>']['fields']['file_ext']=array(
    'name' => 'file_ext',
    'vname' => 'LBL_FILE_EXTENSION',
    'type' => 'varchar',
    'len' => 100,
);
$dictionary['<object_name>']['fields']['file_mime_type']=array(
    'name' => 'file_mime_type',
    'vname' => 'LBL_MIME',
    'type' => 'varchar',
    'len' => '100',
);
$dictionary['<object_name>']['fields']['uploadfile']=array(
    'name'=>'uploadfile',
    'vname' => 'LBL_FILE_UPLOAD',
    'type' => 'file',
    'len' => '255',
    'dbType' => 'varchar',
);
  1. Create the file custom/Extension/modules/<module_name>/Ext/Language/en_us.fileupload.php with the code:
<?php
$mod_strings['LBL_FILE_UPLOAD'] = 'This is file of the record'; // You can use other text for label
  1. Edit or create the file custom/modules/<module_name>/metadata/editviewdefs.php and custom/modules/<module_name>/metadata/detailviewdefs.php (if you create it you can copy the file from modules/<module_name>/metadata/editviewdefs.php and modules/<module_name>/metadata/detailviewdefs.php). Add some lines:
...
array (
  'EditView' => 
  array (
    'templateMeta' => 
    array (
      'form' => 
      array (
        'enctype' => 'multipart/form-data', // add the line into the file editviewdefs.php only
...
    'panels' => 
    array (
      'lbl_...' => 
      array (
...
/* add the array */
          1 => 
          array (
            'name' => 'uploadfile',
          ),
...
  1. Edit the file modules/<module_name>/<object_name>.php and add the function to object (for example modules/Accounts/Account.php):
    function deleteAttachment($isduplicate="false")
    {
		if($this->ACLAccess('edit'))
        {
			if($isduplicate=="true")
            {
				return true;
			}
			$removeFile = "upload://{$this->id}";
		}

		if(file_exists($removeFile)) 
        {
			if(!unlink($removeFile)) 
            {
				$GLOBALS['log']->error("*** Could not unlink() file: [ {$removeFile} ]");
			}
            else
            {
				$this->uploadfile = '';
                $this->filename = '';
				$this->file_mime_type = '';
				$this->file = '';
				$this->save();
				return true;
			}
		} 
        else 
        {
			$this->uploadfile = '';
			$this->file_mime_type = '';
			$this->file = '';
			$this->save();
			return true;
		}
		return false;
	}

Notes:

  1. Changes of the file modules/<module_name>/<object_name>.php will not supported by upgrade SuiteCRM. After upgrade you should repair the code.
  2. Names of
    – all system objects (<object_name>) is singular noun.
    – all system modules (<modules_name>) is plural noun.
    – all custom objects and modules are plural noun.

Great solution!

These core files can be overridden in an upgrade-safe way, here is an example:

@pgr
Yes! I thought that this was very many for one time.

Excellent article u wrote. Great. Its works nice.