samedi 27 décembre 2014

Get the filename of the first attachment in a list item



I have a custom view form for my list. The form needs to display the contents of the list item as well as the photo that is attached to the list item. Currently I am having the end user copy and paste the filename into a separate column and using that to complete the src for the <img> tag.


I have used the following code to display the image on the .aspx form:


<img border="0" src="/Lists/Barring Records/Attachments/{@ID}/{@photo}" style="max-width: 1000px; max-height: 600px;"/>


where @ID is the list item ID and @photo is the copy-and-paste filename. This works but is awful for the end user.


Is there a way to find and reference the first attachment for the list item and insert it where the {@photo} goes? I do not care about any other attachments but the first. I would prefer to do this on the form page, but can put the code elsewhere if instructed.


I have SharePoint Foundations 2010








0 commentaires:

Enregistrer un commentaire