LinkedIn is the most successful professional social network with more than 60 million users worldwide. At the end of the last year LinkedIn opened up their API for developers allowing third parties to integrate the valuable information on their applications. The information contained in this social network is specially relevant when working with CRM applications. For example, it can be very useful to know how you are connected with a sales lead.
After having a look to the widgets available on the LinkedIn API, I thought that it would be a nice feature to have some sort of quick integration within Dynamics CRM. For example displaying the LinkedIn company insider widget on the account form, allowing us to quickly discover what connections we have with an account and easily jump to LinkedIn to get more details.
As you can see in the picture, the idea is to attach this widget using an icon next to the company name. When a user clicks on the icon a nice popup is displayed showing how he/she is connected with that company.
The code to achieve this is not too complicated. Just required some minor adjustments to ensure a proper visualisation within the Microsoft Dynamics CRM form.
function LinkedInLoader(crmFormField) {
var ll = this;
ll.scriptSource = 'http://www.linkedin.com/companyInsider?script&useBorder=yes'
ll.field = crmFormField;
ll.container = crmFormField.parentNode;
ll.nameToSearch = crmFormField.DataValue;
ll.spanId = ll.field.id + '_linkedin';
if (ll.container != null) {
var span = document.createElement('span');
span.id = ll.field.id + '_linkedin';
var td1 = document.createElement('td');
td1.innerHTML = ll.container.innerHTML;
var td2 = document.createElement('td');
td2.appendChild(span);
td2.style.width = '15px';
var tr = document.createElement('tr');
tr.appendChild(td1);
tr.appendChild(td2);
var table = document.createElement('table');
table.width = '100%';
table.style.tableLayout = 'fixed';
table.cellSpacing = 0;
table.cellPading = 0;
table.appendChild(tr);
ll.container.innerHTML = table.outerHTML;
}
ll.ApplyCorrections = function() {
var div = document.getElementById('company-insider-info-window');
if (div != null) div.style.height = '275px';
else window.setTimeout(ll.ApplyCorrections, 500);
}
ll.Enable = function() {
new LinkedIn.CompanyInsiderPopup(ll.spanId, ll.nameToSearch);
new LinkedIn.CompanyInsiderStylesheet();
var span = document.getElementById(ll.spanId);
if (span != null) span.attachEvent('onclick', ll.ApplyCorrections);
}
ll.OnScriptReadyState = function() {
if ((event.srcElement.readyState == 'complete') ||
(event.srcElement.readyState == 'loaded')) {
ll.Enable();
}
}
ll.Load = function() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = ll.scriptSource;
script.onreadystatechange = ll.OnScriptReadyState;
document.getElementsByTagName('head')[0].appendChild(script);
}
}
if (crmForm.FormType != 1) {
// Set the field that contains the company name
var linkedInLoader = new LinkedInLoader(crmForm.all.name);
linkedInLoader.Load();
}
This code works by getting the name of the company from the text field that you indicate when firing the LinkedInLoader script. Make sure that you provide a valid CRM form text field.
Over the next days I will publish a new version that also enables the LinkedIn contact widget to use it with CRM Contacts. Stay tuned!
Hope you find it useful, enjoy it!
This post was mentioned on Twitter by marcoamoedo: New blog post: http://tinyurl.com/y9uoac3 – Adding LinkedIn to Dynamics CRM
Just a small bit of code placed in just the right place. Sometimes the biggest business benefit is not
Any way to do this over HTTPS? As far as I can tell, https://linkedin.com just redirects you to http://linkedin.com.
This is a problem for those of us who run CRM over HTTPS as you get a nice message asking if you would like to display unsecure content every time you load an account.
Thanks for this – very neat. By any chance have you published the script for Contacts?
Did you manage to get it to work with contacts?
[…] to get information about my CRM contacts directly. This can be done for Accounts (ie companies) as explained in this article by CRM MVP Marco Amoedo. I must get round to going through the solution to see how it might be possible to modify it for […]
[…] […]