【问题标题】:JavaScript Get SharePoint Online List from AppJavaScript 从 App 获取 SharePoint Online 列表
【发布时间】:2016-04-12 00:06:52
【问题描述】:

我的 SharePoint Online 列表位于网站集级别

mydomain/sites/dev/Lists/MyList

我正在开发一个自定义的 SharePoint 托管应用程序,该应用程序正在运行

mydomain/sites/dev/MyApp

我目前有这段 javascript 代码:

var siteUrl = 'mydomain/sites/dev';
var clientContext = new SP.ClientContext(siteUrl);
var oList = clientContext.get_web().get_lists().getByTitle('MyList');

我得到一个错误:

Request failed. List 'MyList' does not exist at site with URL 
mydomain/sites/dev/MyApp

所以我需要以某种方式访问​​父/根网络...

我试过像这样添加.get_rootWeb()

var oList = clientContext.get_web().get_rootWeb().get_lists().getByTitle('MyList');

然后我得到:

JavaScript runtime error: Object doesn't support property or method 'get_rootWeb'

我错过了什么吗?

【问题讨论】:

    标签: javascript sharepoint web add-in sharepoint-online


    【解决方案1】:

    我通过替换解决了我的问题

    var oList = clientContext.get_web().get_lists().getByTitle('MyList');
    

    与

    var oList = clientContext.get_site().get_rootWeb().get_lists().getByTitle('MyList');
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-04
      • 2020-12-27
      • 1970-01-01
      • 1970-01-01
      • 2017-07-02
      相关资源
      最近更新 更多