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();


        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.executeQueryAsync(Function.createDelegate(this, this.linkInfo), Function.createDelegate(this, this.onQueryFailed));


    function linkInfo() {

        var contactEnum = contactList.getEnumerator();
        var taskEnum = taskList.getEnumerator();
        var holder = '<br/>';
        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>";

I think the issue is with your referencing the Display Name of the column instead of the Internal name. In the get_item() method, you will have to pass the Internal name of the Contact ID field. It will never contain spaces. It should most probably be something like Contact_x0020_ID. You can find out the exact internal name of the column with the steps mentioned in the following link:


  • Thank You, you're right. I checked the source and the ID of my field was as you said it was :) – user10319 Aug 24 '12 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.