I'm trying to retrieve a lookup field using :
var lookup = ($(this).attr("ows_shARePublishTo_x003a_shAReSiteUR"));
Other columns seem to work fine, including another lookup column
The column name is:
Field=shARePublishTo%5Fx003a%5FshAReSiteUR
But keep getting undefined when I alert lookup. it seemed to work fine before I added and removed column from Library and Content Type.
Any ideas?
Most of code:
var sliderList = "shARe Applications"; // Name of the list that contains slides
var ListContentField = "shAReAppDesc"; //Internal Name of the Rich text field that has slide content
var ListBackgroundImageField = "shARe_x0020_Application_x0020_Ic"; //Internal Name of the picture field to use as background image
var ListTitle="Title";
var ListLink = "shAReAppURL";
var thisSite = $().SPServices.SPGetCurrentSite();
var siteURL = thisSite + "/SRE";
var build = new String();
//query to retrieve all items
var query = "<Query><Where><Neq><FieldRef Name='ID' /><Value Type='Number'></Value></Neq></Where></Query>";
$().SPServices({
operation: "GetListItems",
async: true,
webURL: siteURL,
listName: sliderList,
// CAMLViewFields: camlViewFields ,
CAMLQuery: query,
completefunc: function(xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
var slideTitle = ($(this).attr("ows_"+ListTitle));
var slideLink = ($(this).attr("ows_"+ListLink));
var slideContent = ($(this).attr("ows_"+ListContentField));
var picture = $(this).attr("ows_"+ListBackgroundImageField);
var filename = picture.substr((picture.lastIndexOf("/")+1),(picture.length));
var thisSite = $().SPServices.SPGetCurrentSite();
var DynamicImageUrl= thisSite+"/SRE/shAReApplicationImages/"+filename;
var link = slideLink.split(",")[0];
var linkText = slideLink.split(",")[1];
//var lookup = ($(this).attr("ows_shARePublishTo_x003A_shARe_x0020"));
//display names !!!
var lookup = ($(this).attr("ows_shARePublishTo_x003a_shAReSiteUR"));
alert(lookup);
//var lookup = lookup +";";
var lookupArray = lookup.split(";");
// get top location, as iFrame used location unknown unless top used.
var TopPath = (window.top.location.pathname).toLowerCase();
for(var i = 0; i < lookupArray.length; i++){
// alert (lookupArray[i]);
var SingleItem = lookupArray[i].toLowerCase();
var PublishTo= SingleItem.substr(SingleItem.lastIndexOf("sites")-1,SingleItem.length);
var TopPath1 = TopPath.substr(0,(TopPath.lastIndexOf("sitepages")-1));
//alert ("URLTopFrame-"+TopPath1);
if (PublishTo == TopPath1)
{
//alert (slideTitle + "match");
$(".carousel").append("<ul style=\"background:#FFFFFF;\"><img src="+ DynamicImageUrl +" style=\"width:35%; height:50%;\" /><span id =\"title\">" + slideTitle+ "</span><BR /><BR /> <div id = \"BodyText\">"+slideContent+ "<BR /><a target= \"_top\" href=\" "+link +" \"> "+ linkText +"</a> "+ "</div>" +"</ul>");
}
} //end lookup array
}); // end for each function
$(this)
is getting initialized? Have you Included that columns as part ofcontext.load
?