This is a multi-part series where we discuss how to integrate SharePoint and Salesforce. There isn’t a one size fits all, I will share a few of the different ways we’ve done it in past projects.
- Best In Class(es): Bringing Salesforce and Office 365 Together. Instead of forcing one platform to do it all, aim to leverage the best of both platforms: Salesforce and Office 365.
- Case management in Salesforce, documents in SharePoint. We created a folder creation process to store case files in SharePoint and giving users the full breadth of document capabilities of SharePoint.
- THIS POST: Uploading files to SharePoint tightly coupled to Salesforce metadata. We created a custom upload form to associate specific metadata from Salesforce to the file in SharePoint, along with providing Salesforce the references to the files.
Coming Up:
- Salesforce Files Connect using a SharePoint Library. A basic approach to displaying files from SharePoint in Salesforce.
- Enterprise search across Salesforce and SharePoint. Search and discovery across both platforms is essential for users, in this approach we created a hybrid search center to allow users to perform searches across both Salesforce and SharePoint.
The first example might suffice for most needs, however, we came across a more targeted need. Lawyers could create dockets, which are official court correspondences for the case, then upload the document and have it tagged with the docket code from Salesforce. We couldn’t let them upload the file directly into a SharePoint library as the docket code and number would be unique for each docket. We didn’t want them to manually enter in the metadata either. Since there would be unique metadata per file, the default column metadata trick we did previously wouldn’t work here.
For this need, we went with a more custom approach. For starters, the docket creation screens in Salesforce were custom VisualForce pages, which was required for the overall functionality but also allowed us to complete the file upload portion of it as well. Upon creating a docket, the user would click a button to add files.
Clicking Add Files would let the user upload files directly into SharePoint.
Note the URL, that’s SharePoint! From here, users could upload files and specify additional metadata. Since this was a docket, we had to validate the file wouldn’t overwrite another file, so we check to make sure the file is legit.
When the files are uploaded, they are placed in a folder for this case, the metadata is set. Meanwhile the user gets a friendly upload status bar. Upon completion, the Salesforce page is notified of the file URLs, and that data is stored in the record and displayed to the user.
We also had an event handler on the library, which would deny deleting files in the Dockets folder, across all cases. If they deleted a docket in Salesforce (which only admins could do) then the file would be deleted from SharePoint via the APIs.
High Level Design
Some technical details
- Salesforce submits all of the metadata about the complainant, respondent, case, and docket(s) to a SharePoint list via a custom Azure API.
- We leveraged the SharePoint PnP JavaScript library and jQuery in the pop window, to query the metadata, perform the necessary validation and upload the file to the library.
- We used
window.opener.postMessage
to notify Salesforce, the opener, of the URLs of the uploaded files. Salesforce then wrote the URLs to the record. - The event handler is hosted in Azure, which denies users from deleting the files but allowing Salesforce to delete it via an API in Azure.
Thanks for your help David. I sent an email to you. Could you please help me?
David, I am trying to setup new site in new salesforce environment and I did the following operations. But I found the error to display the docket summary.
1. Created new resource group in Azure
2. Created new pubxml file to the existing docket solution
3. Download the profile from Azure Portal for the newly created Resource Group
4. Update the necessary details in pubxml file based on the profile and did the deployment from Visual Studio
5. Added New Remote Site under Security Controls in Salesforce
6. Updated the CUSTOM_URL section to point out new SharePoint site & docket URL
Error: Content cannot be displayed: Expected DocketFileExtension.DocketSendError but found “invalid URL: https://test.sharepoint.com/sites/sitename/” at [line:1, column:44]
Please help me.
Where is the error being reported?
David – The error is displaying in the Docket Files layout. After click the Docket Name link for the case, it displays the above error. When I check the Developer Console, it provides the below error.
23:26:23:398 CALLOUT_REQUEST [273]|System.HttpRequest[Endpoint=https://salesforcedeletedocketdev2.azurewebsites.net/api/dockets, Method=PUT]
23:26:23:709 CALLOUT_RESPONSE [273]|System.HttpResponse[Status=Bad Request, StatusCode=400]
23:26:23:709 USER_DEBUG [277]|DEBUG|Response Body: {“Message”:”ERROR”,”RequestID”:0,”Errors”:[“invalid URL: https://test.sharepoint.com/sites/obc-cases-dev2/“]}
23:26:23:711 FATAL_ERROR System.JSONException: Expected DocketFileExtension.DocketSendError but found “invalid URL: https://test.sharepoint.com/sites/obc-cases-dev2/” at [line:1, column:44]
Please help me on this.
Hi Phil,. email me, david.lozzi at slalom.com. This code looks remarkably familiar :D
I am in the middle of struggling. Anyway I will learn the Azure App Service API and try to identify it.
Sure David, If you could post that series, it will be helpful to me. Please help me for the below question. In that salesforce solution, file upload API is deployed to Azure and it is automatically uploading Web Registration Cards into SharePoint document library with every 2 to 3 minutes. I am unable to get the information from Salesforce or from Azure portal. Please guide me.
I won’t be able to cover it all in a post series, there’s a lot in there and I don’t have access to the environment anymore. Again, you can start with understanding Azure Web APIs, that’s the big middle man between Salesforce and SharePoint Online. Here’s more info about the Azure service https://azure.microsoft.com/en-us/services/app-service/api/
David, how do I change the SharePoint site URL when we click Document Management button and Add files button?
Which Site URL? Do you mean in the popup window? Or when uploading is done?
David,
Sorry for late reply. Yes, but I found it from CustomURLs settings page. You have written some web api to create entry in list and then you are calling from Apex class. I want to know how to do the deployment of web api to Azure?
Thanks for your help.
That’s a very large question with a large answer. I’m not sure we can cover this over email or the blog post here. I’d start with searching for web APIs in Azure to learn that piece, then create an API to connect to SharePoint. Sorry, I can’t provide more specific code…
In there any chance, you will be posting the implementation details for uploading files to sharepoint.
not sure how much more I can share, as that’s the secret sauce my client paid for. What more would you want?