I'm having an issue when I'm trying to grab a column I made in the tasks list (it's a lookup column). for some reason when i'm try to access it with javascript i always get an exception that it isn't initialized. i run the caml query and that run ok, and i am able to get some information from the task list, like title and status, but not the column i made.
Here is my code. The problem comes in when i try to access "Contact ID" in the linkInfo method. any help would be great. Thank You.
function test() {
var newClientContext = new SP.ClientContext.get_current();
var oWebsite = newClientContext.get_web();
this.collList = oWebsite.get_lists();
var Caml = new SP.CamlQuery();
var taskCaml = new SP.CamlQuery();
Caml.set_viewXml('<View></View>');
var getContactList = oWebsite.get_lists().getByTitle("Contacts");
var getTasksList = oWebsite.get_lists().getByTitle("Tasks");
this.contactList = getContactList.getItems(Caml);
this.taskList = getTasksList.getItems(Caml);
newClientContext.load(contactList);
newClientContext.load(taskList);
newClientContext.executeQueryAsync(Function.createDelegate(this, this.linkInfo), Function.createDelegate(this, this.onQueryFailed));
}
function linkInfo() {
var contactEnum = contactList.getEnumerator();
var taskEnum = taskList.getEnumerator();
var holder = '<br/>';
alert(contactList.get_count());
while (contactEnum.moveNext())
{
var oContact = contactEnum.get_current();
holder += oContact.get_item('Title')+": ";
while (taskEnum.moveNext()) {
var oTask = taskEnum.get_current();
if (oContact.get_id() == oTask.get_item('Contact ID')) {
holder += oTask.get_item('Title') + ", " ;
}
}
holder += "<br/>";
taskEnum = taskList.getEnumerator();
}
document.getElementById("visualization").innerHTML = "<p>" + holder + " </p>";
}