This project has moved. For the latest updates, please go here.

GetListItems call not completing

Dec 9, 2014 at 2:34 AM
I'm currently bug fixing a script of mine which performs some list lookups using the GetListItems operation.

I am starting to experience intermittent, yet frequent problems with my script 'stopping' at the point where I attempt to assign variable names to the returned data. I have attempted to step through this using Firebug and the console and have confirmed that data is being returned, yet when the script steps into the .each function it stop - no error (apparently), nothing.

I have had this script working well before now, so I know that it does work. Indeed, I have other scripts using the GetListItems operations all over the place without problem, so I am at a loss is to diagnose what is causing it to fail in this way.

I am running SP Services 2014.01 and jQuery 1.11.1 against SharePoint Online 2013.

I'm wondering if anyone else might have experienced this and can offer some suggestions?

``` $().SPServices({
    operation: "GetListItems",
    async: false,
    listName: "Employee List",
    CAMLQueryOptions: "<QueryOptions><ExpandUserField>True</ExpandUserField></QueryOptions>",
    CAMLQuery: "<Query><Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>"+$empID+"</Value></Eq></Where></Query>",
    CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef Name='BranchJobID' /></ViewFields>",
    completefunc: function (xData, Status) {
        console.log("Emp List Call Response = " + xData.responseText); ``` ___<<<___SCRIPT IS FINE TO HERE___
      $(xData.responseXML).SPFilterNode("z:row").each(function() {
        $thisEmpName = $(this).attr("ows_Title"); ``` ___<<<___SCRIPT REACHES HERE THEN STOPS___
        var $branchJobId = $(this).attr("ows_BranchJobID");

        //get jobType from Branch Job list using BranchJobID
            operation: "GetListItems",
            async: false,
            listName: "Branch Job",
            CAMLViewFields: "<ViewFields><FieldRef Name='Job_x0020_Type' /></ViewFields>",
            CAMLQuery: "<Query><Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>"+ $branchJobId +"</Value></Eq></Where></Query>",
            completefunc: function (xData, Status) {
              $(xData.responseXML).SPFilterNode("z:row").each(function() {
                $jobTypeLookup = $(this).attr("ows_Job_x0020_Type");
                console.log("Lookedup Job Type = " + $jobTypeLookup);
              }); //end each
            } //end completefunc
          });  //end SPServices

      }); //end each 
    } //end completefunc 
}); //end GetListItems 

The data returned is
<rs:data ItemCount="1">
   <z:row ows_Title='Alphonse Brown' ows_BranchJobID='78' ows_Requires_x0020_PC='No' ows_Car_x0020_Entitlement_x0020_Setu='No' ows_Apparel_x0020_Provisioning_x0020='Yes' ows_NRDInitialised='Yes' ows_ADMIN_x002d_ForceUpdate='No' ows__Level='1' ows_Car_x0020_Entitlement='No' ows_Requires_x0020_Company_x0020_Clo='Yes' ows_JobInductionHeld='Yes' ows_InductionTrainingSkillsCreated='Yes' ows_Phone_x0020_Entitlement='Yes' ows_Requires_x0020_Desk_x0020_Phone='No' ows_RecruitmentProcessComplete='Yes' ows_CurrentTrainingReviewOS='Yes' ows_Pay_x0020_Basis='Wage' ows_Requires_x0020_Timesheet='Yes' ows_Contracted_x0020_Hours='0' ows_Requires_x0020_Workspace='No' ows_Timesheet_x0020_Setup_x0020_Task='Yes' ows_Gender='Male' ows_MetaInfo='99;#' ows_Bank_x0020_Signatory='No' ows_Internet_x0020_Banking_x0020_Acc='No' ows_Phone_x0020_Setup_x0020_Task_x00='Yes' ows_ID='99' ows_owshiddenversion='45' ows_Created='2014-02-27 22:23:16' ows_Requires_x0020_O365='No' ows_Employee_x0020_Status='Active' ows_HRInductionHeld='Yes' ows_HealthIns='No' ows_PermMask='0x7fffffffffffffff' ows_Leave_x0020_Entitlement='4.00000000000000' ows_IT_x0020_Setup_x0020_Tasks_x0020='N/A' ows_Workspace_x0020_Setup_x0020_Task='N/A' ows_FileRef='99;#sites/dev/Lists/Employee List/99_.000' ows_EmploymentStartDateConfirmed='Yes' ows_PersonalContTaskComplete='Yes' ows__ModerationStatus='0' ows_Company_x0020_Credit_x0020_Card='No' ows_Fin_x0020_Auth_x0020_Setup_x0020='N/A' ows_UniqueId='99;#{62330FC4-7FB2-42A9-8A86-FE8457C2EEF9}' ows_FSObjType='99;#0' ows_Requires_x0020_Workspace_x0020_f='No' ows_NewColumn10='Yes' ows_PayrollSetUpTaskComplete='Yes' ows_Modified='2014-08-27 00:00:05' />
Dec 9, 2014 at 3:36 AM
It could be that you aren't explicitly declaring $thisEmpName. I think I've noticed a few "use strict;" additions to the SharePoint scripts. Since those script can load in different orders, it might explain the intermittent problem and why it is just showing up now.