2012-04-10 194 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}