admin管理员组文章数量:1277362
How can I load items from a SharePoint list using its InternalName? As far as I know I can get it using either Id or Title like the following:
var clientContext = new SP.ClientContext('/News/');
var web = clientContext.get_web();
var list = web.get_lists().getById("{1DBA9283-0AFA-4FA1-9BBA-70D8D190971F}");
...
How can I load items from a SharePoint list using its InternalName? As far as I know I can get it using either Id or Title like the following:
var clientContext = new SP.ClientContext('/News/');
var web = clientContext.get_web();
var list = web.get_lists().getById("{1DBA9283-0AFA-4FA1-9BBA-70D8D190971F}");
...
Share
Improve this question
asked Jan 8, 2012 at 12:30
Ahmed MagdyAhmed Magdy
6,0408 gold badges46 silver badges76 bronze badges
0
4 Answers
Reset to default 2no the CSOM only offers methods to query lists by it's Id or Title.
See http://msdn.microsoft./en-us/library/ee549620.aspx
The SharePoint List Schema doesn't offer InternalNames at the moment. See the Schema description http://msdn.microsoft./en-us/library/ms415091.aspx
Thorsten
Its always remended getting lists using ListUrl , which is not changed when List Title changes.
I don't know if you mean that, but inside my JavaScript-File I'm able to use Object Model if I declare these three lines first.
/// <reference name="MicrosoftAjax.js" />
/// <reference path="file://C:/Program Files/Common Files/Microsoft Shared/Web Server Extensions/14/TEMPLATE/LAYOUTS/SP.core.debug.js" />
/// <reference path="file://C:/Program Files/Common Files/Microsoft Shared/Web Server Extensions/14/TEMPLATE/LAYOUTS/SP.debug.js" />
This is relevant code, works without call with {SelectedItem} or stuff:
var items = SP.ListOperation.Selection.getSelectedItems();
var listID = SP.ListOperation.Selection.getSelectedList();
This loads (parts) of the Client Object Model, so I guess there you can go on. Because this is supported with IntelliSense.
Edit2: The other way to get and use a list with JavScript only is
var web;
var context;
var listTitle = "ListName";
function InitiateThisScript(itemId) {
context = new SP.ClientContext.get_current();
web = context.get_web();
list = web.get_lists().getByTitle(listTitle);
item = list.getItemById(itemId);
context.load(web;
context.load(list);
context.load(item);
context.executeQueryAsync(handleItem(item, list));
}
This way requires in your Elements.xml, where I defined my buttons, that you call it
CommandAction="javascript:InitiateThisScript('{SelectedItemId}','');" />
Edit3: Be careful using this JavaScript without any security checks. Because for example you have delivered this solution to a site, which has lets say two lists. First one you suggested to have this JavaScript and a second one. If you have custom buttons that appears in both list than you work on second list, but using the buttons fire to the first list as long as it is possible.
Lets say you have a button that clears content and you have in both lists a column called "title". If you are on second list and press button "delete title" than on your first list the title from item with same itemId will be deleted. On your second list happens nothing.
This appears from visibility of your buttons and no check, if designated list is the one you are working on.
Shegit
Edit: Scrolling my tabs I found this one: Retrieve items from a folder with EcmaScript & COM
I think that was you who asked the same question on sharepoint stackexchange. Just to link to my answer there, here is the link. There I give a plete example how you can get sharepoint lists using their "internalName" (url)
本文标签: Get SharePoint list by Internal Name using ECMAScriptJavaScript Object ModelStack Overflow
版权声明:本文标题:Get SharePoint list by Internal Name using ECMAScriptJavaScript Object Model - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741258516a2367155.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论