远程事件接收器在添加文档时更新标题? [英] Remote event receiver to update Title when a document is added?
问题描述
我一直在看PnP Core.EventReceiver 示例
项目如何在线部署RER到Azure for SharePoint。
它在AppInstalled上创建一个通用列表,附带一个接收器,当我运行它并添加一个项目代码工作时科幻ne并且它更新了描述。
列表 照片 = clientContext 。 Web 。 列表 。 GetById ( listId );
ListItem 项目 = 照片 。 GetItemById ( listItemId );
clientContext 。 加载 ( item );
clientContext 。 ExecuteQuery ();
item [ "描述" ] + = " \ n更新的RER" + 系统 。 日期时间 。 现在 。 ToLongTimeString ();
item 。 更新 ();
clientContext 。 ExecuteQuery ();
我将列表模板ID更改为101而不是通用列表:
creationInfo 。 TemplateType = ( int ) < span class ="typ"style ="margin:0px;填充:0像素;边框:0像素;字体风格:继承;字体变:继承;字体重量:继承;行高:继承; FONT-FAMILY:继承;垂直对齐:基线;颜色:#2b91af"> ListTemplateType 。 DocumentLibrary ;
它创建了一个库,当我创建一个新文档时,事件接收器仍然没有发生错误但是在文档中我得到了一个非常一般的错误 "抱歉,
我们遇到了问题"
将RER附加到文档库而不是通用列表时,是否需要做任何不同的事情?
< blockquote>
请远程接收远程事件接收器并检查它是否有效。
将网站添加到"可信站点"或"本地内部网",然后检查它是否有效。
如果要将远程事件接收器添加到所有文档库,我们可以打开AppManifest.xml文件,然后转到选项卡权限,在作用域列中设置Web,以及权限列管理值。
然后修改HandleAppInstalled方法以循环遍历列表,然后将RER附加到所有文档库列表。
最好的问候,
丹尼斯
I've been looking at the PnP Core.EventReceiver sample project how to deploy a RER to Azure for SharePoint online.
It creates a generic list on AppInstalled with a receiver attached, when I run it and add an item the code works just fine and it updates the description.
List photos = clientContext.Web.Lists.GetById(listId);
ListItem item = photos.GetItemById(listItemId);
clientContext.Load(item);
clientContext.ExecuteQuery();
item["Description"] += "\nUpdated by RER " + System.DateTime.Now.ToLongTimeString();
item.Update();
clientContext.ExecuteQuery();
I changed the list template id to 101 instead of generic list:
creationInfo.TemplateType = (int)ListTemplateType.DocumentLibrary;
It creates a library and the event receiver is still firing without an error when I create a new document but inside the document I get a very generic error "Sorry,
we ran into a problem"
Do I have to do anything differently when attaching a RER to a document library instead of a generic list?
Hi,
Please remote the remote event receiver and check if it works.
Add the site to "Trusted sites" or "Local intranet", then check if it works.
If you want to add the remote event receiver to all document library, we can open AppManifest.xml file, then go to the tab Permissions, in the Scope column set Web, and Permissions column Manage value.
And then modify HandleAppInstalled method to loop thorough the lists and then attach the RER to all document library list.
Best Regards,
Dennis
这篇关于远程事件接收器在添加文档时更新标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!