I am using the client side object model to approve multiple items from the form library. I need to access the values of some of the columns of the form library. The following is my code:

      var context;
       var web;
       var itemCount;
       var count = 0 ;
       SP.UI.Notify.addNotification('Approving item(s)...');
       function approveItems ()
         context = SP.ClientContext.get_current();
         web = context.get_web();
         var currentLibId = SP.ListOperation.Selection.getSelectedList();
         var currentLib = web.get_lists().getById(currentLibId);          

          // Get all the items in the list
          employees = currentLib.getItems(); 
          // Load the web in the context and retrieve only selected columns to improve performance 
          context.load(this.employees, 'Include(ID,FirstName)');              
          alert('after load.');

        function get_Employees_onSuccess() {
           // Get the collection
           alert('inside success..');
           var employeeCollection = this.employees.getEnumerator();          
           alert('employeeCollection' +employeeCollection);
           while (employeeCollection.moveNext()) {
              var employee = employeeCollection.get_current();
              alert('id: ' +employee.get_item('ID'));
              alert('FirstName: ' + employee.get_item('FirstName'));              
        function get_Employees_onFailure() {
           alert('An error occurred while fetching data. Please contact your system administrator.');

When I deploy the solution and test, the alert of the onFailure is displayed. I am not able to figure out the reason why the code in onSuccess is not executing.

Please guide.

2 Answers 2


You can debug your app with error handling like this:

function onFailure(sender, args) {
    ULS.enable = true;
    ULSOnError(args.get_message(), document.location.href, 0);
    //if debugging
  • Where can I see the logs? In the ULS Log viewer? Commented Sep 9, 2013 at 8:48

getItems takes SP.CamlQuery object as parameter. If you need all items use ID > 0. Forexample:

camlQuery.set_viewXml('<View><Query><Where><Geq><FieldRef Name=\'ID\'/>' + 
        '<Value Type=\'Number\'>1</Value></Geq></Where></Query>


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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