Dear ragesoft,
All you need to do, is add an
Image column to the Contacts list. Image column can be either Hyperlink or Picture column type. Storing picture in Attachments might not be the best thing as there can be multiple attachments per file, but if you can have Hyperlink column that always has the correct URL, this will be much easier.
You will also need to know the Internal names of the First Name and Last Name columns, they can be different from their title, for example, "First_x0020_Name" and "Last_x0020_Name" - that's how SharePoint stores names with spaces. You can check internal names if you go to List Settings, open the column and check its name in URL:
- InternalNameListSettings.png (15.06 KiB) Viewed 10929 times
Now, that you know both the Internal Names of First Name and Last Name, as well as the URL/Picture field for Image, simply insert the following Request Items code to the Cross-site Lookup:
Code: Select all
function (term, page) {
if (!term || term.length == 0) {
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Image,First_x0020_Name,Last_x0020_Name&$orderby=Created desc&$top=10";
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Image,First_x0020_Name,Last_x0020_Name&$orderby={LookupField}&$filter=startswith({LookupField}, '" + term + "')&$top=10";
}
And the following code to Item Format:
Code: Select all
function(item) {
return '<div style="clear: both; height: 25px;">' +
'<div style="width: 45px; float: left;"><img style="margin-top: 3px;" src="' + item.Image.Url + '"></div>' +
item["First_x0020_Name"] + item["Last_x0020_Name"] +
'</div>';
}