Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

How do I get list properties like BaseTemplate, ItemCount, ListItemDeletedDate etc. via Javascript Client Object Model for SharePoint 2013?

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Okay, so I got some answers on MSDN which were very helpful.

Here is the code-snippet which helped me:

<script type="text/javascript" src="/_layouts/15/init.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.js"></script>

<script type="text/ecmascript">
    var customlist ;
    function GetListInformation(listGuid) {
        var clientContext = new SP.ClientContext.get_current();
        var oWebsite = clientContext.get_web();
        customlist = oWebsite.get_lists().getById(listGuidId);
        clientContext.load(customlist);
        clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
    }       

    function onQuerySucceeded() {
         alert("Last item deleted time : " + this.customlist.get_lastItemDeletedDate() );
         alert("Base Type ID : " + this.customlist.get_baseType());
         alert("Item Count : " + this.customlist.get_itemCount());

    }

    function onQueryFailed(sender, args) {
        alert(" Failed");
    }       
</script>
share|improve this answer
1  
here's rest of properties if you need, msdn.microsoft.com/en-us/library/ee547487(v=office.14).aspx –  Muhammad Raja Apr 16 '13 at 8:39
add comment

Could you not get your properties using REST? Unfortunately I don't have access to my SharePoint 2013 machine for testing myself, but the URL would be similar to http://'site'/_api/web/lists/getbytitle('listName'). You can play about directly in the browser to see the results. Once you have found the correct REST command, you could then use $.ajax() to call within your javascript.

I've written a blog about cross domain REST calls, that won't have your answer, but you will be able to see how to write a ajax call to rest.

http://cann0nf0dder.wordpress.com/2013/04/14/cross-domain-and-sharepoint-hosted-apps-using-rest/

I hope it helps.

share|improve this answer
    
Thank you for this. I actually need this for another project. –  Daniel Ziga Apr 16 '13 at 8:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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