My client has multi language SharePoint 2013 environment.I am developing a sharepoint hosted app for my client, but when i try to access any library or list using its name e.g. getByTitle('site pages')...it is giving me an error(List not found) in sites with language other than English. Please suggest me any solution how to access list or libraries in different sites with different languages.
-
1you can use "GetList" method and use internal name instead.– Bhaskar DhoneCommented Dec 29, 2015 at 12:59
-
"GetList" is not available in client side code(javascript). If you able to do it can you please give me any reference link or a complete example. Thanks....@BhaskarDhone– MohitCommented Dec 30, 2015 at 7:52
-
ohh My bad , I just missed SharePoint Online. Instead of getByTitle , you can user 'getById(guid);' Let me know if it helps– Bhaskar DhoneCommented Dec 30, 2015 at 8:03
-
Actually i have to create a single add-in solution for different sites. Different sites will have different GUID for the list with same name. Example 'site pages' library will have different GUID for each site. Thats why i can't use GUID. @BhaskarDhone– MohitCommented Dec 30, 2015 at 9:49
Add a comment
|
1 Answer
While browsing through other similar Stackexchange questions I found this post containing the exact answer to your question although Microsoft documentation doesn't say anything about it.
var context = SP.ClientContext.get_current();
var list = context.get_web().getList("/sites/dev/Lists/Addresses");
context.load(list);
context.executeQueryAsync(function() {
alert("loaded!");
}, function() {
alert("failed!");
});
I've tried the code in my console and I was able to load a list based on the url no matter if I changed the title or not.