Announcement

Collapse
No announcement yet.

Rename uploaded files/attachments

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Rename uploaded files/attachments

    Hi there,
    is there a way to make file/attachment field enable so the user can be able to rename files/attachments after upload?
    Thanks

  • #2
    Hello Athensmusic,

    In fact, there is no such possibility. The user must reupload the file with a new name

    Comment


    • #3
      Hi Athensmusic,

      For one file, it is possible to make such functionality quite simple.

      We will work in the entity where you need to change the file name.
      1. Go to the Administration > Entity Manager and select this entity.
      2. As far as I understand, you already have a field of type Attachment Multiple (in my example, it will be called attachment). In addition to it, create a field of type Varchar named nameOfAttachment.
      3. Go to the Layout Manager of this entity and drag the Attachment and Name of Attachment fields to the Detail View.
      4. Go to the Formula of this entity and paste this formula:
      Code:
      $attachmentId = array\at(attachmentIds, 0);
      $oldName = record\attribute('Attachment', $attachmentId, 'name');
      
      $format = string\match($oldName, '/[^.]*$/');
      
      $nameOfAttachment = string\concatenate(nameOfAttachment, '.', $format);
      
      ifThen(
             nameOfAttachment != null,
             record\update('Attachment', $attachmentId, 'name', $nameOfAttachment)
           );
      Last edited by lazovic; 08-17-2022, 01:41 PM.

      Comment


      • esforim
        esforim commented
        Editing a comment
        Hi... although it is August but it look like we have a new Forum Mod. Thank you for solution.

      • Athensmusic
        Athensmusic commented
        Editing a comment
        Oh, this is a good solution and it could easily get improved for multiple attachments using one more field.
        One varchar field the user should type the old file Name or ID, so formula could get the ID by the given name and a second varchar field fo type the new name.
        All this seems like an "emergency" solution, not that easy for many multiple attachment fields.
        Was expecting something really easy like inline editing etc.

        Thanks!!
    Working...
    X