At work, we are using Salesforce.com to meet the needs of several departments. We’ve extended the platform to not just manage CRM data, but to track other business processes as well. We also use Sharepoint to manage documents, publish dashboards, and maintain our event calendar.
On several occasions, I have expressed my desire for Salesforce and Sharepoint to talk to each other, but apparently it’s not that easy to do without developing web services or purchasing off the shelf solutions. Both of these paths are currently off the table for my small team, so we went a different direction with the tools that are available in Salesforce and Sharepoint.
Background
We have been using attachments functionality in Salesforce to keep documents with their corresponding records, but we have found that attachments are a less than optimal way to manage documents, because they are not searchable and they are difficult to export en masse if we need to move to a different Salesforce instance (we will soon). We have also looked at Salesforce Content Management, but it takes too many clicks for users to upload files and attach the files to a record. (We could do some custom stuff to make this work, but we don’t have the time or resources).
Solution
So, we decided to use Sharepoint as our document manager and provide links in Salesforce that reference the Sharepoint documents. We figured out a relatively quick and easy way of doing this that includes the following steps. Only the first two steps are manual. (see below).
The ingredients needed to make this work include:
Starting in Sharepoint:
- Create a Document Library in Sharepoint with at least a field to house the Salesforce ID and Salesforce Name. We also created a Document Type field (e.g. Contract, MOU, Application, etc).
- Create a custom edit form (copy the editform.aspx), and place a Content Editor Webpart below the form. In the CEWP add a javascript that parses a query string. (See below – Thanks to Josh for putting this together).
<script src="/_layouts/jquery-1.3.2.min.js" type="text/javascript"></script> <script type="text/javascript">// <![CDATA[
$(document).ready(function(){
var sfID = GetUrlKeyValue('SalesforceID');
$('input[title="SalesforceID"]').val(sfID);
var SFRecordType = GetUrlKeyValue('SalesforceRecordType');
$('input[title="SalesforceRecordType"]').val(SFRecordType);
var SFName = GetUrlKeyValue('SalesforceName');
$('input[title="SalesforceName"]').val(SFName);
});
// ]]></script>
- Make the Custom Edit Form the default Edit Form for that library.
Moving to Salesforce:
- Create a custom object called Document and include Document Type as a field and a lookup field to the object to which you will be attaching the documents. (e.g. If the document library will be housing documents related to Accounts, then add a lookup field to Accounts object.)
- Create a “New Document” button in the Document object with a URL to directed to Sharepoint. You can get the beginning part of the URL by uploading a new document into your Sharepoint List and copying the URL in the address bar. It will look something like this:
http://SiteCollectionName/SiteName/_layouts/Upload.aspx?List=%7BD9F024A7%2D3E1D%2D4475%2D890F%2D973E19D5E997%7D&Root Folder=%2SiteName%2FSalesforceDocuments&Source=http%3A%2F%2F newsource%2Eapollogrp%2Eedu%2FGovtAffairs%2FGATeam%2F SalesforceDocuments%2FForms%2FAllItems%2Easpx%3FFilterField1%3D SalesforceID%26FilterValue1%3D{!Account.Id}&SalesforceID{!Account.Id}& SalesforceName={!Account.Name}
This will generate the url that will be parsed by the code above in the Sharepoint CustomEditForm.
- Go to the Account Object Page Layout (or whichever related object to which you will be attaching your documents) and make sure that the Documents Object is showing as a related list. In the Document Object, select the new button that you created in the previous step.
Congratulations, you just created a way to upload new documents Sharepoint from Salesforce. Give it a try. Go to an account and click the “New Document” button, and you’ll be taken to your Sharepoint site, where you can upload a new document. The Salesforce ID and Document Types should have been passed to the Sharepoint form as well.
But we are not done yet! Next we’ll learn how to send back the Document information from Sharepoint to the Document Object in Salesforce using workflow in Sharepoint and Email Services in Salesforce. Once complete, the document information will show up in the Account Page Layout on the related Document list with a link directly to the actual document in Sharepoint.
Ever thought about going back to that one critical moment or decision you made when you were 18? Maybe it was about a girlfriend/boyfriend; or a class you took; a bet you made (or didn’t); or a vacation you took.



