从Sharepoint-Online中的子站点更新父站点列表 [英] Update Parent site List from sub-site in Sharepoint-Online
问题描述
我正在使用远程事件接收器来监听子站点中存在的文档库。
代码与此实现有些相似: https://github.com/SharePoint/PnP/tree/master/Samples/Core.EventReceivers
我想要更新/插入父站点中存在的列表。
因此,只要文档库的子站点/子站点发生变化,事件接收器就会流动执行并且父站点列表中应该有一个条目。
我应该如何实现它?我有子站点/子站点的clientcontext。我可以检索ParentId和其他属性,如下所示:
var web = clientContext.Web;
var parentWeb = web.ParentWeb;
clientContext.Load(parentWeb);
$
clientContext.ExecuteQuery();
如何加载父列表&更新它吗?
如果我做了以下的事情:
              ClientContext parentClientContext = new ClientContext(" https:// parentsite /");
             列出myList = parentClientContext.Web.Lists.GetByTitle(" TestProjectMetrics");
              ListItemCreationInformation itemInfo = new ListItemCreationInformation();
              ListItem myItem = myList.AddItem(itemInfo);
              myItem [" Title"] =" My New Item2"; $
              myItem [" ProjectDurationMonths"] =" New Item Description2"; $
              myItem.Update();
              parentClientContext.Credentials = clientContext.Credentials; //  ;clientContext.Credentials给出空值
              parentClientContext.ExecuteQuery();
        clientContext.Credentials给出空值
FYI:clinetContext是子站点上下文。
您好
您可以在前4行代码中获得parentWeb吗?
如果是这样,您可以使用parentWeb对象加载列表
I am working on remote event receiver which listen to a document library exist in a sub-site.
Code is somewhat similar to this implementation : https://github.com/SharePoint/PnP/tree/master/Samples/Core.EventReceivers
I want to update / insert a List which exist in Parent Site.
So the flow is, whenever something change in sub-site / child site of document library, event receiver will execute and there should be an entry in Parent site List.
How should I implement it ? I have clientcontext of sub-site / child site. I can retrieve ParentId and other property like below:
var web = clientContext.Web;
var parentWeb = web.ParentWeb;
clientContext.Load(parentWeb);
clientContext.ExecuteQuery();
How to load parent List & update it ?
If I go something below:
ClientContext parentClientContext = new ClientContext("https://parentsite/");List myList = parentClientContext.Web.Lists.GetByTitle("TestProjectMetrics");
ListItemCreationInformation itemInfo = new ListItemCreationInformation();
ListItem myItem = myList.AddItem(itemInfo);
myItem["Title"] = "My New Item2";
myItem["ProjectDurationMonths"] = "New Item Description2";
myItem.Update();
parentClientContext.Credentials = clientContext.Credentials; // clientContext.Credentials is giving null value
parentClientContext.ExecuteQuery();
clientContext.Credentials is giving null value
FYI : clinetContext is sub-site context.
Hi
Can you get parentWeb in your first 4 line codes?
If so, you can use the parentWeb object to load list.
这篇关于从Sharepoint-Online中的子站点更新父站点列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!