我正在尝试在 Dynamics CRM (2011) 中弹出一个包含有关 LinkedIn 帐户信息的弹出窗口,如此处所示http://www.altiadvisors.com/Portals/0/Adding%20LinkedIn%20to%20Dynamics%20CRM%20 -%20Aug2010%20CRM%20Tip.pdf
我已将一个字段附加到表单,该字段应更改为具有表单的 onLoad 功能的按钮。这在FunctionName
例如警报中使用了一段简单的 javascript,但是当我尝试使用 Linked In 集成添加更复杂的脚本时,我在 Internet Explorer 中打开了一个空白窗口,并且按钮没有改变。
恐怕我对 javacript 很陌生,我看不出错误在哪里。我的另一个担心是 Linked In 部分是为 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();
//}
}