2

Environment: Sitecore 9.3

I have a Sitecore Form which consists of the following fields:

  • First Name (Single-line Text)
  • Last Name (Single-line Text)
  • Attachments (Native File Upload Component)
  • Submit Button

Attachments are stored in ExperienceForms Database, table: sitecore_forms_filestorage.FileStorage. How to create a functionality where URL should be generated for each uploaded file to download it directly?

1 Answer 1

2

You can get the list of all form entries from the ExperienceForms Database.

            var result = new List<FormEntry>();
            var output = dataProvider.GetEntries(formId, startDate, endDate);
            if (output != null && output.Any())
                result = output.ToList();

for GetEntries, you can use IFormDataProvider interface.

namespace Sitecore.ExperienceForms.Data
{
  public interface IFormDataProvider
  {
    IReadOnlyCollection<FormEntry> GetEntries(
      Guid formId,
      DateTime? startDate,
      DateTime? endDate);

    void CreateEntry(FormEntry entry);

    void DeleteEntries(Guid formId);
  }
}

I've not worked on storage but based on my understanding so far, I think you can create a custom FileStorageProvider class and generate the link field property based on your need -

https://doc.sitecore.com/developers/93/sitecore-experience-manager/en/manage-file-storage-for-forms.html

So the idea is if you have [FormItemID] reference in storage, you can first get the forms, (As mentioned above) and based on [FormItemID] reference you can get the files from the custom repository with the custom property of link.

I hope these details will help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.