Most of the customers prefer to use SharePoint as there document storage. CMost of the cases you may able to use the OOB SharePoint - Dynamics CRM integration.
https://community.dynamics.com/crm/b/magnetismsolutionscrmblog/archive/2017/12/19/setting-up-server-based-sharepoint-integration-for-dynamics-365-online
But sometimes you may need to extend the OOB SharePoint - Dynamics CRM integration to meet client's expectations.
To develop this kind of third party solutions, SharePoint client object model (CSOM) can be used.
So there are two methods to develop this kind of solution for Dynamics 365 Online.
- Use the share point Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll and use the standerd methods.
https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/ee537013(v%3doffice.14)
But in Dynamics 365 Online, there is a limitation that only one dll can be resisted and it won't be allowed to register other dlls for referencing.
There you need to merge your custom solution dll with Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll using a dll merging technique. - Create a custom solution by calling the SharePoint REST Api with web requests.
Following is a example of crating a folder in SharePont document library using REST Api. Same way you can create, delete, update records in SharePoint.
There are some helper classes which are needed to execute following sample methods. You can find the helper classes here.
public class SharePointService { private string _username; private string _password; private string _siteUrl; private SpoAuthUtility _spo; public SharePointService(string username, string password) { _username = username; _password = password; } /// <summary> /// For creating folder in sharepoint /// </summary> /// <param name="siteUrl">The site URL.</param> /// <param name="relativePath">The relative path.</param> public string CreateFolder(string siteUrl, string relativePath) { if (siteUrl != _siteUrl) { _siteUrl = siteUrl; Uri spSite = new Uri(siteUrl); _spo = SpoAuthUtility.Create(spSite, _username, WebUtility.HtmlEncode(_password), false); } string odataQuery = "_api/web/folders"; byte[] content = ASCIIEncoding.ASCII.GetBytes(@"{ '__metadata': { 'type': 'SP.Folder' }, 'ServerRelativeUrl': '" + relativePath + "'}"); string digest = _spo.GetRequestDigest(); Uri url = new Uri(String.Format("{0}/{1}", _spo.SiteUrl.ToString().TrimEnd('/'), odataQuery)); // Set X-RequestDigest var webRequest = (HttpWebRequest)HttpWebRequest.Create(url); webRequest.Headers.Add("X-RequestDigest", digest); // Send a json odata request to SPO rest services to fetch all list items for the list. byte[] result = HttpHelper.SendODataJsonRequest( url, "POST", // reading data from SP through the rest api usually uses the GET verb content, webRequest, _spo // pass in the helper object that allows us to make authenticated calls to SPO rest services ); string response = Encoding.UTF8.GetString(result, 0, result.Length); return response; } }
If you need code samples to create/update/delete list items and documents, please let me know in comment section.