0

I'm working with sugar 8.3. I'm trying to create custom field for upload documents. I have create vardef file, but when I click on save record, file uploaded properly but not display in record.

custom/Extension/modules/Opportunities/Ext/Vardefs/custom_upload.php

<?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,

);

Before save attachment screenshot

After save attachment screenshot

  • You have to be more specific. What have you tried? What went wrong? Include snippets of configuration and log files as relevant. – mhvelplund Mar 25 '19 at 12:18

1 Answers1

0

The whole scenario is not very clear from the code you have provided, i think that you should remove 'source'=>'non-db', attribute from these fields so that they get saved in database.

Don't forget to perform Repair and execute queries that gets generated in result of repair so that Sugar create appropriate fields in opportunities table for saving you uploaded file data.

Sheikh Rahat Ali
  • 1,293
  • 8
  • 37
  • 61