Need custom file upload field with delete functionality

Hi All,

I need a custom file upload field on Cases module. For this purpose I followed completely this blog (www.bhea.com/blog/creating-file-upload-field-core-modulecustom-module-sugar-7-x/).

I'm able to upload file but deletion of file is not working.

Any help will be highly appreciable.

Regards

Parents
  • Hi Juned Rawoot,

    You should extend the bean class to custom directory and add new method "deleteAttachment" to it to make it work.

    You can copy this method from Notes bean class - modules/Notes/Note.php.

    Steps to do it:

    1. Extend/override your module bean to custom directory - Sugar Bean Override Not Working 

    2. Copy "deleteAttachment" function from Note.php to your new custom bean file.

    3. Perform quick repair and rebuild.

    Please let us know if this helps.

    Regards.

    Hats

  • Hi hats

    I'm working with sugar 8.3 and trying to create custom upload field in opportunity.  

    Requirement:

    1) I can upload file from create and edit.

    2) I can see the file in record view as a link.

    3) After clicking on link, the file must download.

     I follow www.bhea.com/blog/creating-file-upload-field-core-modulecustom-module-sugar-7-x/ this example. 

    Now problem is I can upload file but file is not showing in record view. 

    /*

    * This is code in vardef file.

    */

    <?php

    $GLOBALS['dictionary']['Opportunity']['fields']['filename'] = array (

    'name' => 'filename',
    'vname' => 'LBL_FILENAME',
    'type' => 'file',
    'dbType' => 'varchar',
    'len' => '255',
    'reportable' => true,
    'comment' => 'File name associated with the note (attachment)',
    'importable' => false,
    'source' => 'non-db',
    'docUrl' => 'doc_url',
    );

    $GLOBALS['dictionary']['Opportunity']['fields']['file_mime_type'] = array(

    'name' => 'file_mime_type',
    'vname' => 'LBL_FILE_MIME_TYPE',
    'type' => 'varchar',
    'len' => '100',
    'comment' => 'Attachment MIME type',
    'importable' => false,
    'source' => 'non-db',
    );

    $GLOBALS['dictionary']['Opportunity']['fields']['file_url'] = array (
    'name'=>'file_url',
    'vname' => 'LBL_FILE_URL',
    'type'=>'varchar',
    'source'=>'non-db',
    'reportable'=>false,
    'comment' => 'Path to file (can be URL)',
    'importable' => false,

    );

    /*

    * This is code in editviewdefs.php file.

    */

    $viewdefs['Opportunity']['EditView'] = array(
    'templateMeta' => array('form' => array('enctype'=> 'multipart/form-data',),));

     

    Help highly appreciated.

  • Hi Juned Rawoot,

    Looking at your vardef, it seems like you have mistakenly given 'filename' field source as 'non-db'.

    This means it won't save your file in database and hence you cannot access it after you save the record.

    Please try to remove this property and give quick repair and rebuild from admin section. Once the repair is successful, you should see a new ALTER table query auto-generated by sugar to create new field "filename" in opportunities table. Please execute that and try again.

    Let us know if this helps.

    Regards.

Reply
  • Hi Juned Rawoot,

    Looking at your vardef, it seems like you have mistakenly given 'filename' field source as 'non-db'.

    This means it won't save your file in database and hence you cannot access it after you save the record.

    Please try to remove this property and give quick repair and rebuild from admin section. Once the repair is successful, you should see a new ALTER table query auto-generated by sugar to create new field "filename" in opportunities table. Please execute that and try again.

    Let us know if this helps.

    Regards.

Children