Delen via


Acties op Sharepoint-locatierecords

 

Gepubliceerd: november 2016

Is van toepassing op: Dynamics CRM 2015

Met behulp van Microsoft Dynamics CRM SDK kunt u de volgende bewerkingen uitvoeren op Microsoft SharePoint-locatierecords.

  • Locatierecords ophalen, bijwerken en verwijderen

  • Stel een sitelocatierecord als standaard in

  • Een documentlocatierecord aan een entiteitrecord koppelen

  • absolute URL's en siteverzameling-URL's voor een locatierecord ophalen

Locatierecords ophalen, bijwerken en verwijderen

Met behulp van de Microsoft Dynamics CRM SDK-berichten op SharePointSite en SharePointDocumentLocation-entiteiten kunt u records maken, ophalen, bijwerken of verwijderen. Om deze bewerkingen op de SharePointSite-entiteit uit te voeren, hebt u de rol Systeembeheerder in Microsoft Dynamics 365 nodig. Voor een lijst met ondersteunde berichten raadpleegt u Berichten en methoden van de entiteit SharePointSite en Berichten en methoden van de entiteit SharePointDocumentLocation.

Notitie

Als u deze bewerkingen uitvoert op SharePoint-locatierecords, worden alleen de gegevens in Microsoft Dynamics 365 gemanipuleert. Hiermee worden de locaties op de SharePoint-server niet gemaakte, bijgewerkt of verwijderd.

Het SharepointSite.ValidationStatus-kenmerk geeft de validatiestatus van de SharePoint-site-URL weer. De mogelijke waarden voor dit kenmerk worden gedefinieerd in de Validatiestatus (sharepoint_validationstatus)-optieset.

Het SharepointSite.ValidationStatusErrorCode-kenmerk geeft de reden van de validatiestatus van de SharePoint-site-URL weer. De mogelijke waarden voor dit kenmerk worden gedefinieerd in de Reden validatiestatus (sharepoint_validationstatusreason)-optieset.

De opslaglocaties op de SharePoint Server zijn hiërarchisch waar de SharePoint-siteverzameling de container is die meerdere locaties kan bevatten, en elke site kan meerdere sites of documentbibliotheken bevatten. Elke documentbibliotheek kan meerdere documentmappen bevatten. Bij het maken van locatierecords in Microsoft Dynamics 365 geeft u het pad of de URL van deze locaties op SharePoint Server op.

De absolute URL van de SharePoint-documentrecords

Dit is de volledige URL van een opslaglocatie op SharePoint. U kunt de absolute URL opgeven met behulp van de eigenschap SharePointSite.AbsoluteURL of SharePointDocumentLocation.AbsoluteURL.

Als u een SharePointSite-record wilt maken door de absolute URL op te geven:


// Instantiate a SharePoint site object.
// See the Entity Metadata topic in the SDK documentation to determine 
// which attributes must be set for each entity.
SharePointSite spSite = new SharePointSite
{
    Name = "Sample SharePoint Site",
    Description = "Sample SharePoint Site Location record",

    // TODO: Change this URL to a valid SharePoint URL.                        
    AbsoluteURL = "http://www.example.com",
};

// Create a SharePoint site record named Sample SharePoint Site.
_spSiteId = _serviceProxy.Create(spSite);

' Instantiate a SharePoint site object.
' See the Entity Metadata topic in the SDK documentation to determine 
' which attributes must be set for each entity.
Dim spSite As SharePointSite =
 New SharePointSite With {
  .Name = "Sample SharePoint Site",
  .Description = "Sample SharePoint Site Location record",
  .AbsoluteURL = "http://www.example.com"
 }
' TODO: Change this URL to a valid SharePoint URL.                        

' Create a SharePoint site record named Sample SharePoint Site.
_spSiteId = _serviceProxy.Create(spSite)

Op dezelfde manier kunt u een SharePoint-documentlocatierecord maken door de absolute URL op te geven:

SharePointDocumentLocation spDocLoc = new SharePointDocumentLocation
{
    Name = "Sample SharePoint Document Location",
    Description = "Sample SharePoint Document Location record",
    AbsoluteUrl = "http://www.example.com/spdocloc"   
};
_spDocLocId = _serviceProxy.Create(spDocLoc);

Absolute URL worden doorgaans opgegeven voor de SharePoint-locatierecords omdat dit de containerobjecten of de bovenliggende objecten zijn waaronder u andere locaties wilt maken voor de opslag en het beheer van uw documenten.

Notitie

Het kenmerk SharePointDocumentLocation.LocationType bepaalt of een SharePointDocumentLocation-record naar een SharePoint-map (0) of naar een OneNote-bestand (1) wijst. Als u een SharePointDocumentLocation -exemplaar (record) maakt, wordt de waarde van het kenmerk SharePointDocumentLocation.LocationType standaard ingesteld op 0 om aan te geven dat het naar een SharePoint-map wijst. Zie Microsoft Dynamics CRM integreren met OneNote 2015 voor meer informatie over OneNote-ondersteuning.

De relatieve URL van de SharePoint-locatierecords

Dit is de relatieve locatie van een locatierecord in verband met de bovenliggende locatierecord op de SharePoint-server. Wanneer u een relatieve URL voor een SharePoint-locatierecord opgeeft, moet u ook het bovenliggende object opgeven waaronder het moet worden aangemaakt.Microsoft Dynamics 365 gebruikt intern de URL van het bovenliggende object om de absolute URL voor het onderliggende object te definiëren. Om bijvoorbeeld een record voor een SharePoint-documentlocatie onder de SharePoint-locate te maken die in het vorige voorbeeld is gemaakt, moet u het volgende opgeven:


// Instantiate a SharePoint document location object.
// See the Entity Metadata topic in the SDK documentation to determine 
// which attributes must be set for each entity.
SharePointDocumentLocation spDocLoc = new SharePointDocumentLocation
{
    Name = "Sample SharePoint Document Location",
    Description = "Sample SharePoint Document Location record",

    // Set the Sample SharePoint Site created earlier as the parent site.
    ParentSiteOrLocation = new EntityReference(SharePointSite.EntityLogicalName, _spSiteId),
    RelativeUrl = "spdocloc",

    // Associate this document location instance with the Fourth Coffee
    // sample account record.
    RegardingObjectId = new EntityReference(Account.EntityLogicalName, _account1Id)
};

// Create a SharePoint document location record named Sample SharePoint Document Location.
_spDocLocId = _serviceProxy.Create(spDocLoc);

' Instantiate a SharePoint document location object.
' See the Entity Metadata topic in the SDK documentation to determine 
' which attributes must be set for each entity.
Dim spDocLoc As SharePointDocumentLocation =
 New SharePointDocumentLocation With {
  .Name = "Sample SharePoint Document Location",
  .Description = "Sample SharePoint Document Location record",
  .ParentSiteOrLocation = New EntityReference(SharePointSite.EntityLogicalName, _spSiteId),
  .RelativeUrl = "spdocloc",
  .RegardingObjectId = New EntityReference(Account.EntityLogicalName, _account1Id)
 }
' Set the Sample SharePoint Site created earlier as the parent site.
' Associate this document location instance with the Fourth Coffee
' sample account record.

' Create a SharePoint document location record named Sample SharePoint Document Location.
_spDocLocId = _serviceProxy.Create(spDocLoc)

De absolute URL van het onderliggende object (documentlocatie in dit voorbeeld) is: "Parent_URL/Relative_URL". In dit voorbeeld is de absolute URL van de documentlocatie dus http://www.example.com/spdocloc.

Relatieve URL's worden normaal gesproken opgegeven wanneer u een locatierecord laag in de hiërarchie wilt maken of als onderliggend record.

Het voordeel van het gebruik van de relatieve URL is dat als u besluit naar een andere SharePoint-server te gaan om uw documenten op te slaan, u alleen maar de absolute URL van het bovenliggende objectlocatierecord (waarschijnlijk een siteverzameling of een siterecord) in Microsoft Dynamics 365 hoeft op te geven. Alle overige records onder in de hiërarchie blijven functioneren omdat de absolute URL's (automatisch bepaald door Microsoft Dynamics 365) niet worden verbroken. Als u voor deze onderliggende locatierecorden absolute URL's had gebruikt, had u de URL's afzonderlijk moeten herstellen.

Stel een sitelocatierecord als standaard in

U kunt een SharePoint-sitelocatierecord als standaard instellen zodat alle documentlocaties met behulp van Microsoft Dynamics 365 automatisch worden gemaakt onder deze locatie. Om een locatielocatierecord als standaard in te stellen, gebruikt u de eigenschap SharePointSite.IsDefault en stelt u dit in op true. U kunt een sitelocatierecord als standaard instellen tijdens het maken of bijwerken van een sitelocatierecord.

Notitie

Het automatisch maken van documentlocatierecords is alleen mogelijk als de doelsite een SharePoint 2010- of SharePoint 2013-server is en Microsoft Dynamics CRM-lijstonderdeel voor SharePoint Server is geïnstalleerd op de doel SharePoint-siteverzameling. Voor meer informatie over de Microsoft Dynamics CRM-lijstonderdeel raadpleegt u Microsoft Dynamics CRM-lijstonderdeel voor Microsoft SharePoint Server.

Een documentlocatierecord aan een entiteitrecord koppelen

U kunt een documentlocatierecord aan een entiteitrecord koppelen. Als u dit doet, worden alle documenten voor de entiteitsrecord opgeslagen op deze locatie op de SharePoint-server. U kunt een SharePoint-documentlocatierecord aan een entiteitrecord koppelen met behulp van de eigenschap SharePointDocumentLocation.RegardingObjectId. In het volgende voorbeeld ziet u hoe u dit kunt doen:


// Instantiate a SharePoint document location object.
// See the Entity Metadata topic in the SDK documentation to determine 
// which attributes must be set for each entity.
SharePointDocumentLocation spDocLoc = new SharePointDocumentLocation
{
    Name = "Sample SharePoint Document Location",
    Description = "Sample SharePoint Document Location record",

    // Set the Sample SharePoint Site created earlier as the parent site.
    ParentSiteOrLocation = new EntityReference(SharePointSite.EntityLogicalName, _spSiteId),
    RelativeUrl = "spdocloc",

    // Associate this document location instance with the Fourth Coffee
    // sample account record.
    RegardingObjectId = new EntityReference(Account.EntityLogicalName, _account1Id)
};

// Create a SharePoint document location record named Sample SharePoint Document Location.
_spDocLocId = _serviceProxy.Create(spDocLoc);

' Instantiate a SharePoint document location object.
' See the Entity Metadata topic in the SDK documentation to determine 
' which attributes must be set for each entity.
Dim spDocLoc As SharePointDocumentLocation =
 New SharePointDocumentLocation With {
  .Name = "Sample SharePoint Document Location",
  .Description = "Sample SharePoint Document Location record",
  .ParentSiteOrLocation = New EntityReference(SharePointSite.EntityLogicalName, _spSiteId),
  .RelativeUrl = "spdocloc",
  .RegardingObjectId = New EntityReference(Account.EntityLogicalName, _account1Id)
 }
' Set the Sample SharePoint Site created earlier as the parent site.
' Associate this document location instance with the Fourth Coffee
' sample account record.

' Create a SharePoint document location record named Sample SharePoint Document Location.
_spDocLocId = _serviceProxy.Create(spDocLoc)

absolute URL's en siteverzameling-URL's voor een locatierecord ophalen

Zoals eerder uitgelegd, volgt SharePoint Server een hiërarchisch model om records op te slaan. Als u een absolute (volledige) URL van een locatierecord in de hiërarchie wilt ophalen en de SiteCollection-URL waaronder de locatierecord aanwezig is, kunt u het bericht RetrieveAbsoluteAndSiteCollectionUrlRequest gebruiken om dit te doen.

Het RetrieveAbsoluteAndSiteCollectionUrlRequest- bericht werkt alleen correct als beide van toepassing zijn:

  • De Microsoft Dynamics CRM-lijstonderdeel voor SharePoint Server is geïnstalleerd op de SharePoint-siteverzameling op de SharePoint 2010- of SharePoint 2013-doelserver. Zie Microsoft Dynamics CRM-lijstonderdeel voor Microsoft SharePoint Server voor meer informatie.

  • De locatierecord voor de bovenliggende SharePoint-siteverzameling bestaat in Microsoft Dynamics 365 en de eigenschap SharePointSite.IsGridPresent is ingesteld op true bij het maken van de bovenliggende locatierecord.

Anders krijgt u een lege waarde of een onjuiste waarde voor de eigenschap SiteCollectionUrl.

Zie RetrieveAbsoluteAndSiteCollectionUrlRequest voor meer informatie.

In het volgende voorbeeld ziet u hoe u het bericht RetrieveAbsoluteAndSiteCollectionUrl moet gebruiken:


// Retrieve the absolute URL and the Site Collection URL
// of the SharePoint document location record.
RetrieveAbsoluteAndSiteCollectionUrlRequest retrieveRequest = new RetrieveAbsoluteAndSiteCollectionUrlRequest
{
    Target = new EntityReference(SharePointDocumentLocation.EntityLogicalName, _spDocLocId)
};
RetrieveAbsoluteAndSiteCollectionUrlResponse retriveResponse = (RetrieveAbsoluteAndSiteCollectionUrlResponse)_serviceProxy.Execute(retrieveRequest);

Console.WriteLine("Absolute URL of document location record is '{0}'.", retriveResponse.AbsoluteUrl.ToString());
Console.WriteLine("Site Collection URL of document location record is '{0}'.", retriveResponse.SiteCollectionUrl.ToString());

' Retrieve the absolute URL and the Site Collection URL
' of the SharePoint document location record.
Dim retrieveRequest As RetrieveAbsoluteAndSiteCollectionUrlRequest =
 New RetrieveAbsoluteAndSiteCollectionUrlRequest With {
  .Target = New EntityReference(SharePointDocumentLocation.EntityLogicalName, _spDocLocId)
 }
Dim retriveResponse As RetrieveAbsoluteAndSiteCollectionUrlResponse =
 CType(_serviceProxy.Execute(retrieveRequest), RetrieveAbsoluteAndSiteCollectionUrlResponse)

Console.WriteLine("Absolute URL of document location record is '{0}'.", retriveResponse.AbsoluteUrl.ToString())
Console.WriteLine("Site Collection URL of document location record is '{0}'.", retriveResponse.SiteCollectionUrl.ToString())

Zie ook

RetrieveAbsoluteAndSiteCollectionUrlRequest
RetrieveAbsoluteAndSiteCollectionUrlResponse
Microsoft Dynamics CRM 2015 integreren met SharePoint
Inleiding tot SharePoint-integratie.
Documentbeheer voor entiteiten inschakelen
SharePoint-integraties-entiteiten
Voorbeeld: Documentbeheer voor entiteiten inschakelen
Voorbeeld: Een SharePoint locatierecord maken, ophalen, bijwerken en verwijderen
Voorbeeld: Absolute URL's en siteverzameling-URL's voor een locatierecord ophalen
Microsoft Dynamics CRM integreren met OneNote 2015

© 2017 Microsoft. Alle rechten voorbehouden. Auteursrecht