7

I have a structure in which we have a field defined as "File" data type. The requirement is to point this to a specific location within "Media Library". We have done this by specifying guid of the folder in source. I have tried path as well instead of guid.

(Using Content Editor) When I create an instance of the template and click on "Open file" link to select a file. I get "Browse" and "Search" option. File selection works fine when I use Browse tab. When I use "Search" tab to select a file I get "The media item could not be found" error (screenshot below).

![The media item could not be found - screenshot]1

I could not find anything in the logs either to help debug. Has anyone faced this issue?

Update: I forgot to mention that selection of search works fine when the source is not specified.

6
  • The File field is an internal Sitecore field type. Sitecore recommends the "Image" field type even for PDF documents. That field will also allow you to search from your root. Depending on your needs, you could also use the "General Link with Search" field type.
    – maz
    Commented Nov 14, 2017 at 15:58
  • Thanks, @maz. File field is among the Simple Types and I doubt if Image will serve the purpose. So, I tried Image type and selecting PDF, I get "The selected item does not contain an image". I forgot to mention that selection from search works fine when the source is not specified.
    – Ramesh
    Commented Nov 14, 2017 at 16:27
  • I would try the General Link with Search. I think the File field type is leveraged by the rich text control and probably should be avoided. Sitecore seriously needs to work on its data architecture documentation.
    – maz
    Commented Nov 14, 2017 at 18:30
  • We tried General Link with Search, the challenge is that it has additional links on the field which are not applicable requiring customization to hide them. Appreciate your help @maz
    – Ramesh
    Commented Nov 15, 2017 at 3:18
  • which version of Sitecore are you using? Commented Dec 4, 2017 at 10:56

2 Answers 2

1

We logged a ticket with Sitecore for this and they acknowledged and provided a patch (KB0676973) to resolve the error.

After the patch, selecting a file from search results works fine if the item belongs to the location defined in "source". You will get the same error when a file outside of "source" location is selected. Sitecore support suggested that we implement code at our end to restrict the search to the "source" location as opposed to showing the content from the entire site.

0

While the fix that @Ramesh shared works, another solution worked in my case. The problem is in fact a Sitecore bug, but it is due to the fact that we had a child folder with the same name as the source folder.

Consider this scenario. When we specify the source as /sitecore/media library/Documents, we will be unable to select Doc 1 and Doc 2, as is noted by the ❌. We can select the ✅ items without issue.

📁 Media Library
 ↳📁 Documents
   ↳📁 Documents
      📄 Doc 1 ❌
   ↳📁 Documents 2
      📄 Doc 2 ❌
   ↳📁 Archived Documents
      📄 Doc 3 ✅
    📄 Doc 4 ✅

From this we can deduce at least 2 true statements, whereby the parent folder of the selected item must:

  1. Not be the same name as the source folder name
  2. Not start with the same name as the source folder

In other words, just rename the folders if you can. However, be mindful that changing the folders could break links to your media library items.

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.