查找返回CRM帐户文档位置的Sharepoint网站URL的odata查询

查找返回CRM帐户文档位置的Sharepoint网站URL的odata查询,odata,dynamics-crm,sharepoint-2013,Odata,Dynamics Crm,Sharepoint 2013,对于给定的帐户,我需要找到Sharepoint网站的URL 我可以获取Sharepoint文档的位置,但我确实需要“父”Sharepoint站点的URL 我已经走了这么远: $expand=sharepointdocumentlocation\u parent\u sharepointsite&$select=Name,sharepointdocumentlocation\u parent\u sharepointsite&$filter=RegardingObjectId/Id eq(guid

对于给定的帐户,我需要找到Sharepoint网站的URL

我可以获取Sharepoint文档的位置,但我确实需要“父”Sharepoint站点的URL

我已经走了这么远:

$expand=sharepointdocumentlocation\u parent\u sharepointsite&$select=Name,sharepointdocumentlocation\u parent\u sharepointsite&$filter=RegardingObjectId/Id eq(guid“{0537BE88-ECFB-E311-A8DE-2C59E5419D10}”)


但是现在我被卡住了。

我认为您必须使用SharePointDocumentLocation中的ParentSiteOrLocation属性。并继续查询,直到您作为父级访问到SharePointSite,然后查询该SharePointSite以获取绝对URL

ParentSiteOrLocation属性将为您提供对父记录的entityreference。这可以是SharePointDocumentLocation或SharePointSite,因此您必须检查entityreference的逻辑名称。然后继续使用父站点或SharePointSite的id查询SharePointDocumentLocation,直到获得站点的URL

获取SharePointDocumentLocation:

?$select=ParentSiteOrLocation&$filter=RegardingObjectId/Id 等式(guid“{0537BE88-ECFB-E311-A8DE-2C59E5419D10}”)

如果SharePointDocumentLocation的父级是SharePointSite,则获取SharePointSite:

“来自父站点或位置的ID”)?$select=AbsoluteURL


SharePointSite也可以有父站点。SharePointSite上的属性AbsoluteURL只有在没有父项时才有值,如果它有父项,则RelativeURL属性将有值。

您可以在CRM中尝试以下消息


您应该能够使用JavaScript完成类似的任务。

谢谢,这两步方法都很有效。我很难在一个请求中完成这一切。
RetrieveAbsoluteAndSiteCollectionUrlResponse ResolveAbsoluteAndSiteCollectionUrl(
IOrganizationService organizationService,
EntityReference target)
{
    var request = new RetrieveAbsoluteAndSiteCollectionUrlRequest
    {
         Target = target
    };

    var response = (RetrieveAbsoluteAndSiteCollectionUrlResponse)organizationService.Execute(request);

    return response;
}