Advertisement
Kenji776

Getting all attachments from object

Aug 22nd, 2012
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. <!-------- Single Attachment Version ---------------->
  3. var html='';
  4. for(var i = 0; i<result.sObjects.length;i++)
  5. {
  6.    var imageId = 'default image id here';
  7.    if(result.sObjects[i].hasOwnProperty('Attachments'))
  8.    {
  9.         imageId = result.sObjects[i].Attachments[0].Id;
  10.    }
  11.    html += '<li><img class="cacheable"  id="'+imageId+'">'+result.sObjects[i].Name+'</li>';
  12.  
  13. }
  14. $('#products').html(html);
  15.  
  16.  
  17.  
  18. <!--------- All attachments version ------------------->
  19. var html='';
  20. for(var i = 0; i<result.sObjects.length;i++)
  21. {
  22.    var imageId = 'default image id here';
  23.    html += '<li>'+result.sObjects[i].Name;
  24.    if(result.sObjects[i].hasOwnProperty('Attachments'))
  25.    {
  26.        html += '<ul>';
  27.        for(var i = 0; i <  result.sObjects[i].Attachments.length; i ++)
  28.        {
  29.         html += '<li><img class="cacheable"  id="'+result.sObjects[i].Attachments[0].Id+'">'+result.sObjects[i].Name+'</li>';;
  30.        }
  31.        html += '</ul>'  
  32.    }
  33.    html += '</li>'  
  34. }
  35. $('#products').html(html);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement