Monday, November 29, 2010

MSCRM: LinkedIn Access from the Account Form

A client recently asked if it would be possible to look at LinkedIn connections right from the Microsoft Dynamics CRM application.

The code below inserted into the On-Load event in a form will display the LinkedIn widget on the account form. When you click on the widget, if you are signed in to LinkedIn, the connections you have with an Account are displayed in a popup.

The code to achieve this is not too complicated. It just requires some minor
adjustments to ensure proper visualization within the CRM form.

This code works by getting the name of the company from the text field that
you indicate when firing the LinkedInLoader script. So, make sure that you
provide a valid CRM form text field when you call the LinkedInLoader.

function LinkedInLoader(crmFormField) {
var ll = this;
ll.scriptSource = ''
ll.field = crmFormField;
ll.container = crmFormField.parentNode;
ll.nameToSearch = crmFormField.DataValue;
ll.spanId = + '_linkedin';
if (ll.container != null) {
var span = document.createElement('span'); = + '_linkedin';
var td1 = document.createElement('td');
td1.innerHTML = ll.container.innerHTML;
var td2 = document.createElement('td');
td2.appendChild(span); = '15px';
var tr = document.createElement('tr');
var table = document.createElement('table');
table.width = '100%'; = 'fixed';
table.cellSpacing = 0;
table.cellPading = 0;
ll.container.innerHTML = table.outerHTML;
ll.ApplyCorrections = function() {
var div = document.getElementById('company-insider-info-window');
if (div != null) = '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.Load = function() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = ll.scriptSource;
script.onreadystatechange = ll.OnScriptReadyState;
if (crmForm.FormType != 1) {
// Set the field that contains the company name
var linkedInLoader = new LinkedInLoader(;

1 comment:

Andriy a33ik Butenko said...

May be it is correct to post the reference to author of this code?