Reply To: Display and click through to attachments on child list

Forums vLooup for SharePoint Display and click through to attachments on child list Reply To: Display and click through to attachments on child list

#9145
AdamP
Participant

Hi Alexander, thanks for the modified code.

We’re very close with this, just a couple of issues that have shown up…

For clarity,a summary of what I’ve ended up with;

CustomJS area of the form (note I’ve edited the image used for the paperclip to a SP2010 path instead of a SP2013 one) ;


function initAttachments(a,item){
	if(item.get_item("Attachments")){
		return "<img style='border:0px;cursor:pointer;' width='16' height='16' alt='Attachments' src='/_layouts/images/attachhd.gif' onclick='getAttachments(\""+item.get_item("ID")+"\");'>";
	}else{
		return "&nbsp";
	}
}

function getAttachments(id){
var url = _spPageContextInfo.webServerRelativeUrl+"/_vti_bin/ListData.svc/Comments("+id+")/Attachments";
	$.getJSON(url, 
		function(data) {
			var b = [];			
			spjs.$.each(data.d.results,function(i,o){
				b.push("<div><a href='"+o.__metadata.media_src+"' target='_blank'>"+o.Name+"</a></div>");
			});
			spjs.dffs.dlgBox(b.join(""),true);
		}		
	)
}

And in the “Special Configurations” text area for the attachments field on the vLookup config;

{"function":"initAttachments"}

This works well – when the paperclip is clicked you get a DFFS dialogue with the attachments listed – see screenshot. The only improvement here would be to have a slightly less overbearing overlay, so that the content behind the dialogue is still shown (similar to OOTB sharepoint dialogue boxes).

The issue I’ve discovered is that with this code set up – the display of child items via the magnifying glass icon breaks – see second screenshot. It looks like it’s losing the item ID of the child item when the child form loads. Field values are filled with “FieldInternalName + ‘field value’ “.

Any idea of the what’s happening here? It’s almost perfect apart from this one glitch.

Thanks

Adam