Hello, I am having some trouble getting a sharepointdocumentlocation entity on CRM to target the correct SharePoint location using relative url. See my code below.
When I run the code and make my way to the parent entity on CRM, I can see the sharepointdocumentlocation entity has been applied with the name "TestFolder2". But when it tries to load up the SharePoint location, it says it can't find the folder "f1ec0efaf82ce61180cb0050568469a8" and pops up a wizard to create a folder. But before I execute the code block below, I also call a method to create the folder in the SharePoint library so I know it is there.
Any suggestions on what I may be overlooking?
ClientCredentials Creds = new ClientCredentials(); Creds.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials; Uri SvcUri = new Uri("https://<crm domain>/XRMServices/2011/Organization.svc"); if (SvcUri != null && SvcUri.AbsoluteUri.Contains("https")) System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object s, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors) { return true; }; using (OrganizationServiceProxy proxy = new OrganizationServiceProxy(SvcUri, null, Creds, null)) { proxy.CallerId = Guid.Parse("1ef8f22b-c6c9-e511-80ca-0050568469a8"); Entity sharepointdocumentlocation = new Entity("sharepointdocumentlocation"); string FetchXML = @" <fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true' > <entity name='sharepointdocumentlocation' > <attribute name='sharepointdocumentlocationid' /> <filter type='and' > <condition attribute='relativeurl' operator='eq' value='lead' /> </filter> </entity> </fetch>"; EntityCollection result = proxy.RetrieveMultiple(new FetchExpression(FetchXML)); Console.WriteLine(result[0].Id); sharepointdocumentlocation["name"] = "TestFolder2"; sharepointdocumentlocation["parentsiteorlocation"] = result[0].Id; sharepointdocumentlocation["relativeurl"] = "f1ec0efaf82ce61180cb0050568469a8"; sharepointdocumentlocation["regardingobjectid"] = new EntityReference("lead", Guid.Parse("f1ec0efaf82ce61180cb0050568469a8")); Guid sharepointdocumentlocationid = proxy.Create(sharepointdocumentlocation); Console.WriteLine(sharepointdocumentlocationid); Console.ReadKey(); }