Del via


Handlinger på SharePoint-placeringsposter

 

Udgivet: januar 2017

Gælder for: Dynamics 365 (online), Dynamics 365 (on-premises), Dynamics CRM 2016, Dynamics CRM Online

Ved hjælp af Microsoft Dynamics 365-SDK kan du udføre følgende handlinger på Microsoft SharePoint-placeringsposter.

  • Oprette, hente, opdatere og slette placeringsposter

  • Angive en webstedsplaceringspost som standard

  • Knytte en dokumentplaceringspost til en objektpost

  • Hente absolutte og URL-adresser til gruppe af websteder for en placeringspost

Oprette, hente, opdatere og slette placeringsposter

Ved hjælp af Microsoft Dynamics 365-SDK-meddelelser på SharePointSite- og SharePointDocumentLocation-objekter kan du oprette, hente, opdatere og slette poster. For at kunne udføre disse handlinger på SharePointSite-objektet skal du have rollen Systemadministrator i Microsoft Dynamics 365. Du kan se en liste over understøttede meddelelser i Objektmeddelelser og metoder for SharePointSite og Objektmeddelelser og -metoder til SharePointDocumentLocation.

Bemærk

Udførelse af disse handlinger på SharePoint-placeringsposter manipulerer kun dataene i Microsoft Dynamics 365. Det opretter, opdaterer eller sletter ikke placeingerne på SharePoint-serveren.

SharepointSite.ValidationStatus-attributten viser valideringsstatussen for SharePoint-stedets URL-adresse. De mulige værdier for denne attribut er defineret i den grupperede indstilling Valideringsstatus (sharepoint_validationstatus).

SharepointSite.ValidationStatusErrorCode-attributten viser årsag til valideringsstatus for URL-adressen til SharePoint-webstedet. De mulige værdier for denne attribut er defineret i den grupperede indstilling Valideringsstatusårsag (sharepoint_validationstatusreason).

Lagerplaceringerne på SharePoint Server er hierarkisk opbygget, hvor SharePoint-gruppen af websteder er den beholder, der kan indeholde flere websteder, og hvert websted kan indeholde flere websteder eller dokumentbiblioteker. Hvert dokumentbibliotek kan indeholde flere dokumentmapper. Mens du opretter placeringsposter i Microsoft Dynamics 365, skal du angive stien eller URL-adressen på disse placeringer på SharePoint Server.

Absolut URL-adresse til SharePoint-placeringsposter

Dette er den fulde URL-adresse for en lagerplacering på SharePoint. Du kan angive den absolutte URL-adresse ved hjælp af egenskaben SharePointSite.AbsoluteURL eller SharePointDocumentLocation.AbsoluteURL.

For at oprette en SharePointSite-post skal du angive den absolutte URL-adresse:


// 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)

På samme måde skal du for at oprette en SharePoint-dokumentplaceringspost angive den absolutte URL-adresse:

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);

Der gives typisk absolutte URL-adresser til SharePoint-webstedsposter, fordi disse er beholderen eller overordnede objekter, hvor du vil oprette andre placeringer til lagring og håndtering af dine dokumenter.

Bemærk

Den SharePointDocumentLocation.LocationType-attributten bestemmer om en SharePointDocumentLocation-post peger på en SharePoint mappe (0) eller på en OneNote fil (1). Når du opretter en SharePointDocumentLocation-forekomst (post), er værdien af SharePointDocumentLocation.LocationType attributten indstillet til 0 som standard for at angive, at den peger på en SharePoint mappe. Du kan få flere oplysninger om OneNote-understøttelsen under Integrere Microsoft Dynamics 365 med OneNote.

Relativ URL-adresse til SharePoint-placeringsposter

Dette er den relative placering af en placeringspost i forhold til dens overordnede placeringspost på SharePoint-serveren. Når du angiver en relativ URL-adresse for en SharePoint-placeringspost, skal du også angive det overordnede objekt, der skal oprettes.Microsoft Dynamics 365 bruger internt URL-adressen for det overordnede objekt til at bestemme den absolutte URL-adresse for det underordnede objekt. For at oprette en post for en SharePoint-dokumentplacering under SharePoint-webstedet, der er oprettet i det forrige eksempel, skal du angive følgende:


// 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)

Absolut URL-adresse på det underordnede objekt (dokumentplacering i dette eksempel): "Parent_URL/Relative_URL". I dette eksempel er dokumentplaceringens absolutte URL-adresse http://www.example.com/spdocloc.

Der gives typisk relative URL-adresser, når du vil oprette en placeringspost lavere nede i hierarkiet eller som en underordnet post.

Fordelen ved at bruge den relative URL-adresse er, at hvis du beslutter at flytte til en anden SharePoint-server for at gemme dine dokumenter, skal du bare opdatere den absolutte URL-adresse for den overordnede objektplaceringspost (sandsynligvis en gruppe af websteder eller webstedspost) i Microsoft Dynamics 365, så alle de andre poster nede i hierarkiet fortsat fungerer som før, fordi de absolutte URL-adresser (bestemmes automatisk af Microsoft Dynamics 365) ikke brydes. Hvis du havde brugt absolutte URL-adresser for disse underordnede placeringsposter, ville du skulle rette URL-adresserne individuelt.

Angive en webstedsplaceringspost som standard

Du kan angive en SharePoint-webstedsplaceringspost som standard, så alle dokumentplaceringer oprettet ved hjælp af Microsoft Dynamics 365 automatisk oprettes under dette websted. Du opretter en webstedsplaceringspost som standard ved at indstille SharePointSite.IsDefault-egenskaben til true. Når du opretter eller opdaterer en webstedsplaceringspost, kan du angive en webstedsplaceringspost som standard.

Bemærk

Automatisk oprettelse af dokumentplaceringsposter er kun mulig, hvis destinationswebstedet er en SharePoint 2010- eller SharePoint 2013-server, og Microsoft Dynamics CRM-listekomponent til SharePoint Server er installeret SharePoint-målgruppen af websteder. Du kan finde flere oplysninger om Komponent til Microsoft Dynamics CRM-liste i Microsoft Dynamics CRM list component til Microsoft SharePoint Server.

Knytte en dokumentplaceringspost til en objektpost

Du kan knytte en dokumentplaceringspost til en objektpost. Når du gør dette, bliver alle dokumenter for objektposten gemt på denne placering på SharePoint-serveren. Du kan knytte en SharePoint-dokumentplaceringspost til et objekt ved hjælp af SharePointDocumentLocation.RegardingObjectId-egenskaben. I følgende eksempel vises, hvordan du kan gøre dette:


// 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)

Hente absolutte og URL-adresser til gruppe af websteder for en placeringspost

Som forklaret tidligere følger SharePoint Server en hierarkisk model for at gemme poster. Hvis du vil hente den absolutte (fulde) URL-adresse på en placeringspost i hierarkiet og den SiteCollection-URL-adresse, hvor placeringsposten er til stede, kan du bruge RetrieveAbsoluteAndSiteCollectionUrlRequest-meddelelsen for at gøre dette.

RetrieveAbsoluteAndSiteCollectionUrlRequest-meddelelsen fungerer kun korrekt, hvis begge er sande:

  • Microsoft Dynamics CRM-listekomponent til SharePoint Server er installeret på SharePoint-gruppen af websteder på SharePoint 2010- eller SharePoint 2013-serveren. Du kan finde flere oplysninger under Microsoft Dynamics CRM list component til Microsoft SharePoint Server.

  • Placeringsposten til den overordnede SharePoint-gruppe af websteder findes i Microsoft Dynamics 365, og SharePointSite.IsGridPresent-egenskaben var angivet til true under oprettelse af den overordnede placeringspost.

Ellers får du en tom værdi eller en forkert værdi for SiteCollectionUrl-egenskaben.

Du kan finde flere oplysninger under RetrieveAbsoluteAndSiteCollectionUrlRequest.

I følgende eksempel vises, hvordan meddelelsen RetrieveAbsoluteAndSiteCollectionUrl bruges:


// 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())

Se også

RetrieveAbsoluteAndSiteCollectionUrlRequest
RetrieveAbsoluteAndSiteCollectionUrlResponse
Integrere Microsoft Dynamics 365 med SharePoint
Introduktion til SharePoint-integration
Aktivere dokumentstyring for objekter
SharePoint-integrationsobjekter
Eksempel: Aktiver dokumentstyring for objekter
Eksempel: Oprette, hente, opdatere og slette en SharePoint-placeringspost
Eksempel: Hente absolut URL-adresse og grupper af websteders URL-adresse for en placeringspost
Integrere Microsoft Dynamics 365 med OneNote

Microsoft Dynamics 365

© 2017 Microsoft. Alle rettigheder forbeholdes. Ophavsret