{"id":244,"date":"2020-03-28T11:52:06","date_gmt":"2020-03-28T11:52:06","guid":{"rendered":"https:\/\/www.techcrm.in\/blogs\/?p=244"},"modified":"2020-09-08T14:53:09","modified_gmt":"2020-09-08T09:23:09","slug":"creating-a-file-field-type-with-multiple-upload-and-download","status":"publish","type":"post","link":"https:\/\/www.techcrm.in\/blogs\/creating-a-file-field-type-with-multiple-upload-and-download\/","title":{"rendered":"Creating a file field type with multiple upload and download"},"content":{"rendered":"\n<p> Like a lot of SuiteCRM the field types are customisable and you can add file type field for upload documents. This post will explain how to add a file field type. <\/p>\n\n\n\n<p>Steps are as below, <\/p>\n\n\n\n<p><strong>Step 1:<\/strong>  Create custom field and we do this by adding a new file&nbsp;<code>custom\/extension\/modules\/&lt;module_name&gt;\/Ext\/Vardefs\/&lt;file_name&gt;.php<\/code>&nbsp;with the following contents:  <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\n$dictionary&#91;'&lt;module_name>']&#91;'fields']&#91;'documents'] = array(\n  'name' => 'documents',\n  'vname' => 'LBL_DOCUMENTS',\n  'type' => 'file',\n  'dbType' => 'varchar',\n  'len' => '255',\n  'reportable'=>true,\n  'importable' => false,\n);\n<\/code><\/pre>\n\n\n\n<p> Create language file for assign name to field and we do this by adding a new file&nbsp;<code>custom\/extension\/modules\/&lt;module_name&gt;\/Ext\/Language\/&lt;file_name&gt;.php<\/code>&nbsp;with the following contents: <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n$mod_strings&#91;'LBL_DOCUMENTS'] = 'Documents';<\/code><\/pre>\n\n\n\n<p><strong>Step 2:<\/strong> Create table with following schema,<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE TABLE 'custom_documents' (\n  'id' varchar(36) NOT NULL,\n  'module_id' varchar(36) NOT NULL,\n  'filename' varchar(200) NOT NULL,\n  'module_name' varchar(200) NOT NULL,\n  'file_mime_type' varchar(255) DEFAULT NULL,\n  'deleted' tinyint(4) NOT NULL\n)<\/code><\/pre>\n\n\n\n<p><strong>Step 3: <\/strong>Add a reference to the JavaScript file which will be needed for event binding.<\/p>\n\n\n\n<p><strong>Path:<\/strong>&nbsp; &nbsp;<code>custom\/modules\/&lt;module_name&gt;\/metadata\/editviewdefs.php<\/code>&nbsp;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\n$viewdefs&#91;'&lt;module_name>']&#91;'EditView']&#91;'templateMeta']&#91;'includes'] =\n    array (\n        array (\n        'file' => 'custom\/modules\/&lt;module_name>\/js\/editview.js',\n        ),\n    );\n?><\/code><\/pre>\n\n\n\n<p><strong>Step 4: <\/strong>Add the JavaScript file you want to include into the location you referenced above(custom\/modules\/&lt;module_name&gt;\/js\/editview.js)<strong>.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$( document ).ready(function() {\n\tvar record_id = $('input&#91;name=\"record\"]').val();\n\t$('#EditView').attr('enctype','multipart\/form-data');\n\tvar x = 1; \/\/initlal text box count\n\t$(\".add_field_button\").click(function(e){ \/\/on add input button click\n\t\te.preventDefault();\n\t\t\tx++; \/\/text box increment\n\t\t\tvar val = x-1;\n\t\t\t$(\".input_fields_wrap\").append('&lt;div>&lt;input type=\"file\" name=\"attachments&#91;'+val+']\" id=\"attachments&#91;'+val+']\" onclick=\"file_size(this.id)\"\/>&lt;a href=\"#\" class=\"remove_field\">Remove&lt;\/a>&lt;\/div>'); \/\/add input box\n\t});\n\t\t\n    $(\".input_fields_wrap\").on(\"click\",\".remove_field\", function(e){ \/\/user click on remove text\n        e.preventDefault(); $(this).parent('div').remove(); x--;\n    });\n\t\n\t$(\".downloadAttachment\").click(function(e) {\n        var fileName = $(this).attr(\"name\");\n        var name = $(this).text();\n        var data = &#91;\n            {\n                \"id\": fileName,\n                \"type\": name.substr((name.lastIndexOf('.') + 1)),\n                \"module\": \"&lt;module_name>\",\n                \"folder\": \"&lt;module_name>\"\n            }\n        ];\n        downloadAttachment(data);\n    });\n\t\n\t$(\".remove_attachment\").click(function(e) {\n        var fileName = $(this).attr(\"name\");\n        var name = $(this).prev().text();\n        var extension = name.substr((name.lastIndexOf('.') + 1));\n        var flag = confirm(\"Are you want to delete \" + name + \" attachment\");\n        if (flag) {\n            removeAttachment(fileName, extension)\n        }\n    });\t\n});\n\nfunction downloadAttachment(data) {\n    var $form = $('&lt;form>&lt;\/form>')\n        .attr('action', 'index.php?entryPoint=&lt;entry_point_name>&amp;action_type=download')\n        .attr('method', 'post')\n        .attr('target', '_blank')\n        .appendTo('body');\n    for (var i in data) {\n        if (!data.hasOwnProperty(i)) continue;\n        $('&lt;input type=\"hidden\"\/>')\n            .attr('name', i)\n            .val(JSON.stringify(data&#91;i]))\n            .appendTo($form);\n    }\n    $form.submit();\n}\n\nfunction removeAttachment(fileName, extension) {\n    $.ajax({\n        url: 'index.php?entryPoint=&lt;entry_point_name>',\n        type: 'POST',\n        async: false,\n        data: {\n            id: fileName,\n            extension: extension,\n            module: 'itb_candidates',\n\t\t\tfolder: '&lt;module_name>',\n\t\t\taction_type: \"remove\"\n        },\n        success: function(result) {\n            var data = $.parseJSON(result);\n            $('&#91;name=' + data.attachment_id + ']').prev().hide();\n            $('&#91;name=' + data.attachment_id + ']').hide();\n        }\n    });\n}<\/code><\/pre>\n\n\n\n<p><strong>Step 5:<\/strong> Set custom created filed in layout (Edit view &amp; Detail view) using studio and find custom created field in below two files and add the following contents <\/p>\n\n\n\n<p><strong>Path:<\/strong><code>custom\/modules\/&lt;module_name&gt;\/metadata\/editviewdefs.php<\/code> &amp;  <code>custom\/modules\/&lt;module_name&gt;\/metadata\/detailviewdefs.php<\/code>  <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>1 => \n       array (\n        'name' => 'resume',\n        'studio' => 'visible',\n        'label' => 'LBL_RESUME',\n\t'customCode' => '{include file=$FILEUPLOAD filename=$ATTACHMENTS}',\n        ),<\/code><\/pre>\n\n\n\n<p><strong>Step 6:<\/strong>  Create two tpl files for detail-view and edit-view with the following contents: <\/p>\n\n\n\n<p><strong>Path:<\/strong><code>custom\/include\/tpls\/editview.tpl<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;div>&lt;input type=\"file\" name=\"attachments&#91;0]\" id=\"attachments&#91;0]\" onclick=\"file_size(this.id)\"\/>&lt;\/div>\n&lt;div class=\"input_fields_wrap\">&lt;div>&lt;\/div>&lt;\/div>&lt;button class=\"add_field_button\">Add More Attachments&lt;\/button>\n{if $fields.id.value != ''}\n{foreach from=$filename key=k item=v}\n\t&lt;br\/>\n\t&lt;a href='#' name={$v.id} id=\"download_attachment{$k}\" class='tabDetailViewDFLink downloadAttachment'>{$v.filename}\u00a0&amp;nbsp&lt;i class=\"glyphicon glyphicon-eye-open\">&lt;\/i>&lt;\/a>\n\t&lt;a href='#' name={$v.id} id=\"remove_attachment{$k}\" class='tabDetailViewDFLink remove_attachment'>\u00a0&amp;nbsp&lt;i class=\"glyphicon glyphicon-remove\">&lt;\/i>&lt;\/a>\n{\/foreach}\n{\/if}<\/code><\/pre>\n\n\n\n<p><strong>Path:<\/strong><code>custom\/include\/tpls\/detailview.tpl<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>{if $fields.id.value != ''}\n&lt;br>\n{foreach from=$filename key=k item=v}\n   &lt;a href='#' name={$v.id} class='tabDetailViewDFLink downloadAttachment'>{$v.filename}\u00a0&amp;nbsp&lt;i class=\"glyphicon glyphicon-eye-open\">&lt;\/i>&lt;\/a>&lt;br \/>\n{\/foreach}\n{\/if}<\/code><\/pre>\n\n\n\n<p><strong>Step 7:<\/strong>  As it is SugarCRM\u2019s module, copy modules\/&lt;module_name&gt;\/views\/view.edit.php to custom\/modules\/&lt;module_name&gt;\/views\/view.edit.php or edit if it already exists at custom\/modules\/&lt;module_name&gt;\/views\/view.edit.php <\/p>\n\n\n\n<p>In function display() add following piece. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public function display(){\n\t\tif(!empty($this->bean->id)){\n\t\t\t$this->ss->assign('ATTACHMENTS',$this->getAttachments($this->bean->id,'itb_candidates'));\n\t\t}\n\t\t$this->ss->assign('FILEUPLOAD','custom\/include\/tpls\/customFileUploadForEditView.tpl');\n\t\tparent::display();\n\t}\nfunction getAttachments($module_id,$module_name){\n\tglobal $db;\n\tif(isset($module_id)){\n\t\t$sql = 'SELECT id,filename FROM custom_documents where module_name = \"'.$module_name.'\" AND module_id = \"'.$module_id.'\" AND deleted = 0';\n\t\t$res = $GLOBALS&#91;'db']->query($sql);\n\t\t$attachments = array();\n\t\twhile($row = $db->fetchByAssoc($res)){\n\t\t\t$attachments&#91;] = $row;\n\t\t}\n\t\treturn $attachments;\n\t}\n}<\/code><\/pre>\n\n\n\n<p> As it is SugarCRM\u2019s module, copy modules\/&lt;module_name&gt;\/views\/view.detail.php to custom\/modules\/&lt;module_name&gt;\/views\/view.edit.php or edit if it already exists at custom\/modules\/&lt;module_name&gt;\/views\/view. detail .php <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public function display(){\n\t\t\/*\n\t\tauthor - Navin Rakhonde\n\t\tdesc - download attachments.\n\t\t*\/\n\t\tif(!empty($this->bean->id)){\n\t\t\t$this->ss->assign('ATTACHMENTS',getAttachments($this->bean->id,'itb_candidates'));\n\t\t}\n\t\t$this->ss->assign('FILEUPLOAD','custom\/include\/tpls\/customFileUploadForDetailView.tpl');\n\t\tparent::display();\n\t}\n\nfunction getAttachments($module_id,$module_name){\n\tglobal $db;\n\tif(isset($module_id)){\n\t\t$sql = 'SELECT id,filename FROM custom_documents where module_name = \"'.$module_name.'\" AND module_id = \"'.$module_id.'\" AND deleted = 0';\n\t\t$res = $GLOBALS&#91;'db']->query($sql);\n\t\t$attachments = array();\n\t\twhile($row = $db->fetchByAssoc($res)){\n\t\t\t$attachments&#91;] = $row;\n\t\t}\n\t\treturn $attachments;\n\t}\n}<\/code><\/pre>\n\n\n\n<p><strong>Step 8:<\/strong>  Create a before save definition logic hook under custom\/modules\/&lt;module_name&gt;\/logic_hooks.php <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n$hook_array&#91;'before_save'] = Array(); \n$hook_array&#91;'before_save']&#91;] = Array(90, 'Attachments', 'custom\/modules\/&lt;module_name>\/uploadAttchments.php','cls_attachments', 'fn_attachments'); <\/code><\/pre>\n\n\n\n<p>Add below code in above created file (custom\/modules\/\/uploadAttchments.php)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\nif (!defined('sugarEntry') || !sugarEntry){\n    die('Not A Valid Entry Point');\n}\n\nclass cls_attachments{\n\t\n    public function fn_attachments(&amp;$bean, $event, $arguments){\n\t\tforeach ($_FILES&#91;\"attachments\"]&#91;\"error\"] as $key => $error) {\n\t\t\tif ($error == UPLOAD_ERR_OK) {\n\t\t\t\t$tmp_name = $_FILES&#91;\"attachments\"]&#91;\"tmp_name\"]&#91;$key];\n\t\t\t\t$name = $_FILES&#91;\"attachments\"]&#91;\"name\"]&#91;$key];\n\t\t\t\t$type = $_FILES&#91;\"attachments\"]&#91;\"type\"]&#91;$key];\n\t\t\t\tfn_upload_attachments($bean->id, $name, $bean->object_name, $type, $tmp_name);\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction fn_upload_attachments($module_id, $name, $module_name, $type, $tmp_name){\n\tglobal $db;\n\t$uploads_dir = $GLOBALS&#91;'sugar_config']&#91;'upload_dir'];\n\t$id = create_guid();\n\t$sql = \" INSERT into itb_documents(id,module_id,filename,module_name,file_mime_type,deleted) VALUES('{$id}','{$module_id}','{$name}','{$module_name}','{$type}','0')\";\n\t$db->query($sql);\n\tif (!file_exists(\"$uploads_dir\/$module_name\")) {\n\t\tmkdir(\"$uploads_dir\/$module_name\", 0777, true);\n\t}\n\tmove_uploaded_file($tmp_name, \"$uploads_dir\/$module_name\/$id\");\n}\n?>\n<\/code><\/pre>\n\n\n\n<p><strong>Step 9:<\/strong>&nbsp; create an file in&nbsp;<em>\\custom\\include\\MVC\\Controller\\entry_point_registry.php<\/em>&nbsp;and add below code, <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\nif(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');\n\nrequire SUGAR_PATH . '\/include\/MVC\/Controller\/entry_point_registry.php';\n$entry_point_registry&#91;'&lt;entry_point_name>']=array('file' => 'custom\/modules\/&lt;module_name>\/&lt;any_name>.php', 'auth' => true);\n\n?><\/code><\/pre>\n\n\n\n<p>Create file custom\/modules\/&lt;module_name&gt;\/&lt;any_name&gt;.php and add below code,<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\nif (!defined('sugarEntry') || !sugarEntry) {\n    die('Not A Valid Entry Point');\n}\nif($_GET&#91;'action_type'] == 'download'){\n\t$data = json_decode(str_replace(\"\"\",\"\\\"\",array_shift($_POST)), true);\n\tglobal $db;\n\tif(!empty($data)){\n\t\t$id = $data&#91;'id'];\n\t\t$module_name = $data&#91;'module'];\n\t\t$query = \"SELECT filename,file_mime_type FROM custom_documents WHERE id= '$id' and module_name = '$module_name' and deleted=0\";\n\t\t$result = $db->query($query);\n\t\t$row = $db->fetchByAssoc($result);\n\t\t$mime_type = $row&#91;'file_mime_type'];\n\t\t$filename = $row&#91;'filename'];\n\t\t$file = 'upload\/'.$data&#91;'folder'].'\/'.$data&#91;'id'];\n\t\theader(\"Content-Description: File Transfer\");\n\t\theader(\"Content-Type: $mime_type\");\n\t\theader('Content-Disposition: attachment; filename=\"'.basename($filename).'\"');\n\t\theader('Expires: 0');\n\t\theader('Cache-Control: must-revalidate');\n\t\theader('Pragma: public');\n\t\theader('Content-Length: ' . filesize($file));\n\t\treadfile($file);\n\t}\n}\n\nif($_POST&#91;'action_type'] == 'remove'){\n\tglobal $db;\n\t$id = trim($_POST&#91;'id']);\n\tif(!empty($id)){\n\t\t$remove_attachments = \"update custom_documents set deleted=1 where id ='$id'\";\n\t\t$result_remove_attachments = $db->query($remove_attachments);\n\t\t\/\/unlink('upload\/'.$_POST&#91;'folder'].'\/'.$id);\n\t\t$data = array();\n\t\t$data&#91;'flag'] = true;\n\t\t$data&#91;'attachment_id'] = $id;\n\t\techo json_encode($data);\n\t}\n\telse{\n\t\t$data = array();\n\t\t$data&#91;'flag'] = false;\n\t\techo json_encode($data);\n\t}\n}<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p> <strong>Note :<\/strong> <\/p><cite><em>Here, &lt;module_name&gt; means the module name you see in the URL, for example, Contacts, Leads, etc.<br>Here, &lt;any_name&gt; means the any file name&nbsp;for example, custom_fields, search_fields, etc.<br>Here, &lt;entry_point_name&gt; means any name as your requirements<\/em> <\/cite><\/blockquote>\n\n\n\n<p>Hope you find this blog post helpful.<\/p>\n\n\n\n<p>Feel free to add comments and queries, that helps us to improve the quality of posts.<\/p>\n\n\n\n<p>You can contact us at&nbsp;<a rel=\"noreferrer noopener\" href=\"mailto:contact@urdhva-tech.com\" target=\"_blank\">info@techcrm.in<\/a><\/p>\n\n\n\n<p>Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Like a lot of SuiteCRM the field types are customisable and you can add file type field for upload documents. This post will explain how to add a file field type. Steps are as below, Step 1: Create custom field and we do this by adding a new file&nbsp;custom\/extension\/modules\/&lt;module_name&gt;\/Ext\/Vardefs\/&lt;file_name&gt;.php&nbsp;with the following contents: Create language file [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,9],"tags":[44,51,52,12,13],"class_list":["post-244","post","type-post","status-publish","format-standard","hentry","category-sugarcrm","category-suitecrm","tag-custom-field-type","tag-file-type","tag-multiple-upload","tag-sugarcrm","tag-suitecrm"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Creating a file field type with multiple upload and download - TechCRM<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.techcrm.in\/blogs\/creating-a-file-field-type-with-multiple-upload-and-download\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Creating a file field type with multiple upload and download - TechCRM\" \/>\n<meta property=\"og:description\" content=\"Like a lot of SuiteCRM the field types are customisable and you can add file type field for upload documents. This post will explain how to add a file field type. Steps are as below, Step 1: Create custom field and we do this by adding a new file&nbsp;custom\/extension\/modules\/&lt;module_name&gt;\/Ext\/Vardefs\/&lt;file_name&gt;.php&nbsp;with the following contents: Create language file [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.techcrm.in\/blogs\/creating-a-file-field-type-with-multiple-upload-and-download\/\" \/>\n<meta property=\"og:site_name\" content=\"TechCRM\" \/>\n<meta property=\"article:published_time\" content=\"2020-03-28T11:52:06+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-09-08T09:23:09+00:00\" \/>\n<meta name=\"author\" content=\"Navin Rakhonde\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Navin Rakhonde\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/creating-a-file-field-type-with-multiple-upload-and-download\/\",\"url\":\"https:\/\/www.techcrm.in\/blogs\/creating-a-file-field-type-with-multiple-upload-and-download\/\",\"name\":\"Creating a file field type with multiple upload and download - TechCRM\",\"isPartOf\":{\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#website\"},\"datePublished\":\"2020-03-28T11:52:06+00:00\",\"dateModified\":\"2020-09-08T09:23:09+00:00\",\"author\":{\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.techcrm.in\/blogs\/creating-a-file-field-type-with-multiple-upload-and-download\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.techcrm.in\/blogs\/creating-a-file-field-type-with-multiple-upload-and-download\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/creating-a-file-field-type-with-multiple-upload-and-download\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.techcrm.in\/blogs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SugarCRM\",\"item\":\"https:\/\/www.techcrm.in\/blogs\/category\/sugarcrm\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Creating a file field type with multiple upload and download\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#website\",\"url\":\"https:\/\/www.techcrm.in\/blogs\/\",\"name\":\"TechCRM\",\"description\":\"Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.techcrm.in\/blogs\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc\",\"name\":\"Navin Rakhonde\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g\",\"caption\":\"Navin Rakhonde\"},\"sameAs\":[\"https:\/\/www.techcrm.in\/\"],\"url\":\"https:\/\/www.techcrm.in\/blogs\/author\/navin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Creating a file field type with multiple upload and download - TechCRM","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.techcrm.in\/blogs\/creating-a-file-field-type-with-multiple-upload-and-download\/","og_locale":"en_US","og_type":"article","og_title":"Creating a file field type with multiple upload and download - TechCRM","og_description":"Like a lot of SuiteCRM the field types are customisable and you can add file type field for upload documents. This post will explain how to add a file field type. Steps are as below, Step 1: Create custom field and we do this by adding a new file&nbsp;custom\/extension\/modules\/&lt;module_name&gt;\/Ext\/Vardefs\/&lt;file_name&gt;.php&nbsp;with the following contents: Create language file [&hellip;]","og_url":"https:\/\/www.techcrm.in\/blogs\/creating-a-file-field-type-with-multiple-upload-and-download\/","og_site_name":"TechCRM","article_published_time":"2020-03-28T11:52:06+00:00","article_modified_time":"2020-09-08T09:23:09+00:00","author":"Navin Rakhonde","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Navin Rakhonde","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.techcrm.in\/blogs\/creating-a-file-field-type-with-multiple-upload-and-download\/","url":"https:\/\/www.techcrm.in\/blogs\/creating-a-file-field-type-with-multiple-upload-and-download\/","name":"Creating a file field type with multiple upload and download - TechCRM","isPartOf":{"@id":"https:\/\/www.techcrm.in\/blogs\/#website"},"datePublished":"2020-03-28T11:52:06+00:00","dateModified":"2020-09-08T09:23:09+00:00","author":{"@id":"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc"},"breadcrumb":{"@id":"https:\/\/www.techcrm.in\/blogs\/creating-a-file-field-type-with-multiple-upload-and-download\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.techcrm.in\/blogs\/creating-a-file-field-type-with-multiple-upload-and-download\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.techcrm.in\/blogs\/creating-a-file-field-type-with-multiple-upload-and-download\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.techcrm.in\/blogs\/"},{"@type":"ListItem","position":2,"name":"SugarCRM","item":"https:\/\/www.techcrm.in\/blogs\/category\/sugarcrm\/"},{"@type":"ListItem","position":3,"name":"Creating a file field type with multiple upload and download"}]},{"@type":"WebSite","@id":"https:\/\/www.techcrm.in\/blogs\/#website","url":"https:\/\/www.techcrm.in\/blogs\/","name":"TechCRM","description":"Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.techcrm.in\/blogs\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc","name":"Navin Rakhonde","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g","caption":"Navin Rakhonde"},"sameAs":["https:\/\/www.techcrm.in\/"],"url":"https:\/\/www.techcrm.in\/blogs\/author\/navin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts\/244","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/comments?post=244"}],"version-history":[{"count":3,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts\/244\/revisions"}],"predecessor-version":[{"id":371,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts\/244\/revisions\/371"}],"wp:attachment":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/media?parent=244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/categories?post=244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/tags?post=244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}