Hi All,
I am trying to display the value of a lookup field without any luck. I have two Lists
List 1 Products: ProductID, Category, Notes
List 2 Category: CategoryID, Title
The products list has a Category column that links to the Title column within the Category list.The code I am having problems with is show below:
function camlQueries() {
var context = SP.ClientContext.get_current();
var web = context.get_web();
var list = web.get_lists().getByTitle("Products");
var query =new SP.CamlQuery();
query.set_viewXml("<View>"+
"<Query>"+
"<Where><Eq>"+
"<FieldRef Name='Category' "+
"LookupId='True' />"+
"<Value Type='Lookup'>1</Value>"+
"</Eq></Where>"+
"</Query>"+
"</View>");
var items = list.getItems(query);
context.load(web, "Title");
context.load(items, "Include(ID, Title");
//context.load(items, "Include(ID, Title, Category");
context.executeQueryAsync(success, fail);
function success() {
var message = jQuery("#message");
message.text(web.get_title());
var ienum = items.getEnumerator();
while (ienum.moveNext()) {
message.append("<br />");
message.append(ienum.get_current().get_item("Title")+ " - ");
// message.append(ienum.get_current().get_item("Category"));
}
}
function fail(sender, args) {
alert("Call failed. Error: "+
args.get_message());
}
}
I hope you can help
Colin