I have a array of list names and I need to fetch ListItemEntityTypeFullName for each of the list. I can fetch the list objects. I need to know if there's any way where I can fetch only the ListItemEntityTypeFullName property for list. Is it possible? Will there be a performance improvement if all properties are fetched and if only a subset of them are fetched?

Below is my code.

var clientContext = new SP.ClientContext.get_current();
var web = clientContext.get_web();
var allLists = web.get_lists();

listnames = ["List 1", "List 2"]; // Array of list titles

var listArray = [];

for (var i = 0; i < listnames.length; i++) {
    var oList = allLists.getByTitle(listnames[i]);

    // Throws error
    //clientContext.load(listArray[i], "Include('ListItemEntityTypeFullName')"); 

clientContext.executeQueryAsync(function (sender, args) {
    // Fetch the ListItemEntityTypeFullName by below command
}, function (sender, args) {debugger});

May I suggest two others roads :)

1 - If my assumption about why you need the ListItemEntityTypeFullName is correct, you may not need it anymore if you change your headers in your requests. You can replace application/json;odata=verbose by application/json;odata=nometadata and never have to send the type of list item.

2 - A Rest call would be really straight forward and would actually make a simpler code : <site-uri>/_api/web/lists?$select=ListItemEntityTypeFullName&$filter=Title eq '<my-list-name' or Title eq '<my-other-list-name' will return the following json object:

    value: Array<{ ListItemEntityTypeFullName: string }>

Hope this helps!

| improve this answer | |
  • I am actually modifying existing code and need to fetch the values in JSOM itself. Plus, the no. lists in the listnames are going to be quite a few. So using JSOM to batch in a single request will be beneficial. – Naveen May 23 '18 at 14:05

Found the issue. Include is used when loading a collection. When adding individual element (list or list item) we need to directly add the property name. Below is the updated code.

clientContext.load(listArray[i], "ListItemEntityTypeFullName");

| improve this answer | |

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.