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.