2

I need to use internal List name in a SPServices function, but when I try, an error occurs.

Example for list with internal name VeiculosOcorrencia, and list title "Veículos Ocorrência":

    $().SPServices({
        operation: 'GetListItems',
        async: false,
        debug: false,
        listName: "VeiculosOcorrencia",
        CAMLQuery: query,
        completefunc: function (xData, Status) {                
            resultados = xData;
         }
    }); 

With this I get error, but works if i change the line to:

listName: "Veículos Ocorrência"
2

SPServices looks for the list Title that is displayed and not the internal list name. If you cannot use the list Title for some reason, is there any reason why you cannot use the list GUID? I would suggest moving to REST or JSOM to perform your GET action for your list data.

Here is a REST example of how to get your list items using the list GUID:

var call = jQuery.ajax({
    url:  _spPageContextInfo.webAbsoluteUrl + "/_api/web/Lists/(guid'your list guid')/Items",
    type: "GET",
    datatype: "json",
    headers: {  Accept: "application/json;odata=verbose"  }
});

call.done(function(data) {
    console.dir(data)
    //read the return JSON and get your data
});

SPServices is great, but it is not the best practice for SharePoint 2013 and above. Hope this helps!

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.