2012-04-10 192 views
0

我嘗試着對LinkedIn帳戶信息獲取的Dynamics CRM中(2011年)的彈出,如在這裏看到http://www.alticoadvisors.com/Portals/0/Adding%20LinkedIn%20to%20Dynamics%20CRM%20-%20Aug2010%20CRM%20Tip.pdfLinkedIn到動態CRM集成

我重視的字段應該改變形式一個帶有窗體onLoad函數的按鈕。這可以在FunctionName中使用一段簡單的javascript工作,例如但是當我嘗試在鏈接集成中添加更復雜的腳本時,我在Internet Explorer中打開一個空白窗口,並且該按鈕不會更改。

恐怕我是一個非常新的javacript,我看不出錯在哪裏。我的另一個擔心是,鏈接部分是爲CRM 4.0編寫的,而我使用的是2011版本,但我不知道在實體中發現和糾正任何錯誤的差異。

以下是我的網絡資源的JavaScript。任何想法或指針將不勝感激。

克里斯

function open() 
{ 
ConvertToButton('new_buttonfield', 'LinkedIn','100px',FunctionName,'Button Label'); 
} 

function ConvertToButton(fieldname, buttontext, buttonwidth,clickevent, title) 
{ 

//check if object exists; else return 
if (document.getElementById(fieldname) == null) 
{ 
    alert("no field by that name"); 
    return; 
} 


functiontocall=clickevent; 
crmForm.all[fieldname].DataValue = buttontext; 
crmForm.all[fieldname].readOnly = true; 
crmForm.all[fieldname].style.borderRight="#3366cc 1px solid"; 
crmForm.all[fieldname].style.paddingRight="5px"; 
crmForm.all[fieldname].style.borderTop="#3366cc 1px solid"; 
crmForm.all[fieldname].style.paddingLeft="5px"; 
crmForm.all[fieldname].style.fontSize="11px"; 
crmForm.all[fieldname].style.backgroundImage="url(/_imgs/btn_rest.gif)"; 
crmForm.all[fieldname].style.borderLeft="#3366cc 1px solid"; 
crmForm.all[fieldname].style.width=buttonwidth; 
crmForm.all[fieldname].style.cursor="hand"; 
crmForm.all[fieldname].style.lineHeight="18px"; 
crmForm.all[fieldname].style.borderBottom="#3366cc 1px solid"; 
crmForm.all[fieldname].style.backgroundRepeat="repeat-x"; 
crmForm.all[fieldname].style.fontFamily="Tahoma"; 
crmForm.all[fieldname].style.height="20px"; 
crmForm.all[fieldname].style.backgroundColor="#cee7ff"; 
crmForm.all[fieldname].style.textAlign="center"; 
crmForm.all[fieldname].style.overflow="hidden"; 
crmForm.all[fieldname].attachEvent("onmousedown",push_button); 
crmForm.all[fieldname].attachEvent("onmouseup",release_button); 
crmForm.all[fieldname].attachEvent("onclick",functiontocall); 
crmForm.all[fieldname].style.lineHeight="14px"; 
crmForm.all[fieldname+'_c'].style.visibility = 'hidden'; 
crmForm.all[fieldname].title=title; 
window.focus(); 

} 

function push_button(){ 
window.event.srcElement.style.borderWidth="2px"; 
window.event.srcElement.style.borderStyle="groove ridge ridge groove"; 
    window.event.srcElement.style.borderColor="#3366cC#4080f0 #4080f0 #3366cc"; 
} 

function release_button(){ 
window.event.srcElement.style.border="1px solid #3366cc"; 
} 


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); 
     } 
} 

// now the definition of the function to call on button click 
function FunctionName() 
{ 
//if (account.FormType != 1) { 
    // Set the field that contains the company name 
    var linkedInLoader = new LinkedInLoader(crmForm.all.name); 
    linkedInLoader.Load(); 
    //} 
} 

回答

1

那麼看這個,有幾件事情...

首先,要動態注射LinkedIn URL是HTTP和HTTPS不是。它也看起來像URL在切換到HTTPS時生成一個語法錯誤。

最好的辦法是使用來自LinkedIn提供的API:https://developer.linkedin.com/documents/getting-started-javascript-api

最後,公司簡介如果引用已被棄用。以下是您要嘗試執行的操作的最新版本:http://developer.linkedinlabs.com/jsapi-console/#examples/company_profile/hover.html& {「framework」:「platform.linkedin.com/in.js","frameworkurl":"","apikey":"","apioptions」: 「」,「sessionbuttons」:true,「async」:false}