I'm trying to create a simple custom action button for the Ribbon menu in Sharepoint 2010.
I want to keep it generic, so no hard coding of library names etc.
How can I find out the name of the current list being viewed? I would imagine that this is possible without having to parse it from the Url.
Many thanks!
To return items from a list, use the GetItemById() method to return a single item, or the GetItems(CamlQuery) method to return multiple items. You then use the Load<T>(T, []) method to attain list item objects that represent the items.
Remarks. Use the ClientContext class to return context information about such objects as the current web application, site, site collection, or server version. The Document library templates sample app for SharePoint includes an example of how to use this object.
JavaScript Object Model (JSOM) is a great value addition for SharePoint development. The articles teach how you can use JSOM script in your application from Clint Browser itself. You can use ECMA Script Client Object Model (JSOM) to retrieve, update, and manage data in SharePoint.
It took a bit of digging, but I found the answer in the end. You can get the Id of the list in Javascript by using:
//Get the Id of the list
var listId = SP.ListOperation.Selection.getSelectedList();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With