我在使用SharePoint 2013(版本15)和Dynamics 365 OnPrem时遇到问题。我已经集成了两个系统,以实现文档管理。一切似乎都工作正常,这种情况是CRM中的电子邮件被转换为案例,然后附件文档以该案例号作为文件夹名称上载到SharePoint中的文件夹。
一切正常,直到我在SharePoint端启用版本控制为止。此后,我的代码立即不起作用,并且出现以下错误字段或属性“ StorageMetrics”不存在。“ Microsoft.SharePoint.Client.ServerException
请参阅下面的代码。
public static void UploadFile(IOrganizationService service, EntityReference sharepointSiteId, EntityReference parentSiteOrLocationId, string fileName, byte[] fileStream, Dictionary<string, object> properties = null, bool overwrite = false)
{
string sharepointSiteUrl = SharepointDocumentLocationManager.RetrieveAbsoluteAndSiteCollectionUrl(service, sharepointSiteId).AbsoluteUrl;
using (ClientContext sharePointContext = SharepointManager.GetClientContext(sharepointSiteUrl))
{
string parentSiteOrLocationUrl = SharepointDocumentLocationManager.RetrieveAbsoluteAndSiteCollectionUrl(service, parentSiteOrLocationId).AbsoluteUrl;
if (overwrite || !SharepointManager.FileExists(sharePointContext, parentSiteOrLocationUrl, fileName))
{
SharepointManager.UploadFile(sharePointContext, parentSiteOrLocationUrl, fileName, fileStream, properties);
}
}
}
public static bool FileExists(ClientContext context, string absoluteBaseUrl, string fileName)
{
Folder folder = context.Web.GetFolderByServerRelativeUrl(absoluteBaseUrl);
context.Load(folder.Files);
context.ExecuteQuery();
return folder.Files.Any(file => file.Name.ToLowerInvariant() == fileName.ToLowerInvariant());
}
此行发生错误。 context.ExecuteQuery();
没有人知道是什么原因造成的,我主要是Dynamics 365开发人员,在SharePoint方面不太了解。请协助。
答案 0 :(得分:0)
可能您的SP SP版本应大于15