sharepoint-online - 远程事件接收器-如何在更新或添加列表项之前获取列表项的附件
问题描述
我想添加限制以在列表项中仅上传一个附件。我实现了附件添加事件,但如果用户删除第二个附件,我无法获得最新的附件计数。
解决方案
您可以使用下面的 CSOM 代码检查附件计数:
List targetList = clientContext.Web.Lists.GetByTitle("List Name");
ListItem oItem = targetList.GetItemById(1);
AttachmentCollection oAttachments = oItem.AttachmentFiles;
clientContext.Load(oAttachments);
clientContext.ExecuteQuery();
Console.WriteLine(oAttachments.Count)
推荐阅读
- reactjs - 将 React Router 与 Switch 一起使用,并且在更改路由时无法让页面呈现不同的组件
- vue.js - Vue:计算属性会监视内部数据变化吗?
- javascript - 如何使用 jQuery 滚动带有按钮的 div?
- drawing - 圆角矩形的对角线尺寸
- python - 带有 '=' 或 '!=' 运算符的数学风格表达式的正则表达式
- docker - NodeJs 复制包到 docker 镜像
- list - 如何在列表中添加括号?
- ckeditor - 有没有办法为 CK Editor 创建自定义插件以支持内联 SVG?
- python - 如何从我的字符串中提取 Url 数据
- tensorflow - UsageError:找不到线魔术函数`%tensorboard`