首页 > 解决方案 > 如何在商机中创建自定义文件上传字段

问题描述

我正在使用糖 8.3。我正在尝试为上传文档创建自定义字段。我已经创建了 vardef 文件,但是当我点击保存记录时,文件正确上传但没有显示在记录中。

自定义/扩展/模块/机会/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,

);

保存附件前截图

保存附件截图后

标签: sugarcrmsugarbean

解决方案


从您提供的代码中,整个场景并不是很清楚,我认为您应该从这些字段中删除'source'=>'non-db',属性,以便将它们保存在数据库中。

不要忘记执行修复并执行在修复结果中生成的查询,以便 Sugar 在机会表中创建适当的字段以保存您上传的文件数据。


推荐阅读