Attachment field

I'm looking to create an ''attachment'' field in a module. Same thing as the field ''File Name'' in the ''Documents'' module.

How can I do that?

Thanks

Parents
  • Hello Dave,

    This was tested in Sugar 7.6.1.0 Professional:

    1. Login as a System Administrator.

    2. Navigate to Admin > Studio > {Sidecar Module such as Accounts} > Fields.

    3. Click 'Add Field'.

    4. Create a new TextField type field and add it to the Record View.

    5. In the Sugar File System, locate the following file:

    ./custom/Extension/modules/{Module}/Ext/Vardefs/sugarfield_{Field Name}.php

    6. Modify this file and add the following line, making the necessary adjustments:

    $dictionary['Account']['fields']['{Field Name}']['type']='file';

    7. Return to the Sugar application and navigate to Admin > Repair.

    8. Select 'Quick Repair and Rebuild'.

    When you create or edit a record in the module where you added the field, it will now display and behave as a File type field that allows you to upload attachments.

    Regards,

    Dan Kallish

    Advanced Support Engineer

    SUGARCRM

    Learning Resources: http://support.sugarcrm.com | http://university.sugarcrm.com | http://community.sugarcrm.com

  • Lori Arce - is this the proper way to add "attachment" field in a module?

    Thanks,

    kgm

  • Hi Dan.

    Thanks for a very thorough explanation. It´s all working until I try to open an already saved attachment in Sugar. The attachment does not keep it´s original name and extension. Instead, it gets a new name, like 315d4014-283d-a1a2-c1a1-572a839cf531, see pic:

    Any idea how that can be fixed (apart from manual renaming)?

    Lori Arce - do you know?

    Thanks again,

    KGM

  • Kristjan,

    This will require more customization in order to retrieve the file name.  Typically, when a note record is created that contains a file attachment, a note record is saved and the attachment is stored on the file system with the Note ID in the ./upload directory.  Reviewing the code, it looks like when one of these attachments are downloaded, Sugar looks at the ./modules/Notes/NoteSoap.php file to determine the file name.

    This custom field that is created using the above method, does not create a note record, so a new customization will need to be added to tell Sugar how to retrieve the original file name.

    Other possible alternatives that you can use that are out of the box are to either:

    1. Use the existing Notes subpanel to attach files, or
    2. Using Module Builder, create a custom document type module and relate it to the module that you would like to attach files to.  This will ensure that attached files do not get lost in the note history (if you have a lot of note history on the record).

    Hope this helps,

    Lori

Reply
  • Kristjan,

    This will require more customization in order to retrieve the file name.  Typically, when a note record is created that contains a file attachment, a note record is saved and the attachment is stored on the file system with the Note ID in the ./upload directory.  Reviewing the code, it looks like when one of these attachments are downloaded, Sugar looks at the ./modules/Notes/NoteSoap.php file to determine the file name.

    This custom field that is created using the above method, does not create a note record, so a new customization will need to be added to tell Sugar how to retrieve the original file name.

    Other possible alternatives that you can use that are out of the box are to either:

    1. Use the existing Notes subpanel to attach files, or
    2. Using Module Builder, create a custom document type module and relate it to the module that you would like to attach files to.  This will ensure that attached files do not get lost in the note history (if you have a lot of note history on the record).

    Hope this helps,

    Lori

Children