Am trying to show all list items in one javascript dynamic table.

I am able to show all list columns except "ATTACHMENT" of that corresponding list item.

Am using below code to get list attachment urls:

function Get_Attachment() {

var Discussion_AttachmentID =10;


attachmentFiles= attachmentFolder.get_files();

    function DiscussionAttachment_onSuccess(sender, args) {                                     
         var i=0;
         for(var file in attachmentFiles) 
              discussionurl= attachmentFiles.itemAt(i).get_serverRelativeUrl(); 

              mydiv = document.getElementById("myDiv");                                    
               var aTag = document.createElement('a');
               aTag.setAttribute('href', discussionurl.toString());
               aTag.innerHTML = "Attached File";



    function DiscussionAttachment_onFailed(sender, args) {

++++++++++++++++++++++++++++++ Now am enumerating all list columns using below:

while (Discussion_enumerator.moveNext()) {

    var Discussion_currentItem = Discussion_enumerator.get_current();

Am able to enumerate other columns but attachment is the issue. As there is no attachment column available in the list.

I have now urls of the list items in the (as mentioned in the above code).

My Idea: Shall i take one hypelink column in the list and add urls (which is available in div) and put it in hyperlink column ??

Please help me how to enumerate or append attachments in the dynamic table.

  • 3
    show code/explain what tech you use SPServices? JSOM? REST? SPFx? PnPJS? Now it is "My car does not start, please help" – Danny '365CSI' Engelman Jan 11 '17 at 12:49
  • hey am using JSOM. – Manish Samal Jan 11 '17 at 13:51
  • good, before we continue, learn how to format Code in your post... read the StackOverflow documentation.... I know.. no-one wants to reads docs... but they are actually worth reading.. Learn the MarkDown language StackOverflow uses and you will create better posts and get better answers – Danny '365CSI' Engelman Jan 11 '17 at 14:12

If you are using REST - use &$expand="AttachmentFiles", if you are using JSOM - use in the load include method add 'AttachmentFiles'

| improve this answer | |
  • Thank you. Am getting all attachment Urls in <div>. Now am stuck with how to enumerate attachment urls and bind it to the dynamic table. – Manish Samal Jan 11 '17 at 15:07
  • Access the urls with this notation: obj.AttachmentFiles.results[0].ServerRelativeUrl; – Shiva Jan 12 '17 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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