SharePoint远程事件接收器-ItemAttachmentAdding不提供正确的计数值

问题描述

在SharePoint Online列表中,我们的要求是限制用户上传多个附件,因此我们实施了RER。

现在在实施ItemAttachment之后添加适当数量的附件将无法正常进行。

还有其他方法可以即时获取附件计数吗?

谢谢。

case SPRemoteEventType.ItemAttachmentAdding:
result = new SPRemoteEventResult();
List list = clientContext.Web.Lists.GetById(properties.ItemEventProperties.ListId);
ListItem listItem = list.GetItemById(properties.ItemEventProperties.ListItemId);
clientContext.Load(listItem);
clientContext.ExecuteQuery();
AttachmentCollection oAttachments = listItem.AttachmentFiles; clientContext.Load(oAttachments);
clientContext.ExecuteQuery();
if (null != oAttachments)
{​​​​
if (oAttachments.Count > 0)
{​​​​
result.ErrorMessage = string.Format("More than one attachment is not allowed");
result.Status = SPRemoteEventServiceStatus.CancelWithError;
}​​​​
}​​​​
else
{​​​​
result.ErrorMessage = string.Format("Something went wrong. Please try again");
result.Status = SPRemoteEventServiceStatus.CancelWithError;
}​​​​

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)