JavaScript几乎无所不能
中文的crm资料太少,群里论坛里响应的人很少,百度搜到的更少
解决了很多技术上的问题,几乎网上都没有,自己决定记录所有开发过程中遇到的问题
crm下拉菜单闪现问题
鼠标移动到菜单后,无法选中,菜单自动消失

造成此问题的原因是安装了瑞星2009,此问题出现在大多数人的机器上,可是没人公布为什么,没人回答,汗一个。
解决方案:1、卸载瑞星。2、鼠标移到菜单后停住,用方向键向下选择
CRM表单多个tab页,tab页的切换、名称动态变化,隐藏,定位问题

该页表单7个tab页,tab页的id从0开始,即tabnTab,
隐藏tab页 crmForm.all.tab1Tab.style.display="none";
显示tab页 crmForm.all.tab1Tab.style.display="block";
更改tab页显示名称:crmForm.all.tab2Tab.innerText="商务条款";
ietoolbar抓到的是text,不好使。
默认定位tab页:crmForm.all.tab2Tab.Click=function{alert("aaa")};
同理tab页切换事件也就有了
公共视图显示关联实体的属性列报错问题
微软的bug,报不出真正错误原因,trace跟踪根本看不出哪儿错了
如果关联实体要显示的列存在CRMmoey类型的属性,那么必须加上基础货币,和关联实体的货币列,不知道为什么,印度人有病。
查找视图多级过滤问题,crm自身只支持关键字查找,想要根据字段查找只能用第三方付费插件,解决方法是自己加fetch xml,切记次xml必须是高级查找视图prompt出来的值
方法是在查找结果的地址栏里输入javascript:prompt("", resultRender.FetchXml.value);
按回车
lookupsingle.aspx页面找个位置加上以下代码,别写table里就行
<script runat="server">
protected override void OnLoad( EventArgs e )
{
base.OnLoad(e);
crmGrid.PreRender += new EventHandler( crmgrid_PreRender );
}
void crmgrid_PreRender( object sender , EventArgs e )
{
// As we don't want to break any other lookups, ensure that we use workaround only if
// search parameter set to fetch xml.
if (crmGrid.Parameters["search"] != null && crmGrid.Parameters["search"].StartsWith("<fetch"))
{
crmGrid.Parameters.Add("fetchxml", crmGrid.Parameters["search"]);
// searchvalue needs to be removed as it's typically set to a wildcard '*'
crmGrid.Parameters.Remove("searchvalue");
// Icing on a cake - ensure that user cannot create new contact outside of the account
// and then select it.
this._showNewButton = false;
}
}
</script>
在onload事件里写
var fetchStr = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+
"<entity name=‘实体名'/>"+
//"<all-attributes/>"+
"<attribute name='属性名'>"+
"<attribute name='属性名'/>"+
"<order attribute='属性名' descending='false'/>"+
"<filter type='and'>"+
"<condition attribute='statecode' operator='eq' value='0'/>"+
"<condition attribute='查询条件的属性名' operator='eq' value='1'/>"+
"</filter >"+
"</entity>"+
"</fetch>";
最恶心的是crm的sdk里给出的js拼fetchxml的方法是错的,全部转换成“<”了,极恶心,调试了半天。而且jimmy wang的博客里的方法里是双引号,不知道这位mvp大哥怎么会犯这种语法错误
下面这句话是屏蔽查找框的作用,这句话很有用,业务方的权限限制很明确,通常查找视图里是不允许你随便查的
crmForm.all.lenovo_classoneitem.lookupbrowse = 1;
一些小技巧
//隐藏左侧工作流菜单
if(window.document.getElementById( 'navAsyncOperations')!=null)
{
window.document.getElementById( 'navAsyncOperations').style.display = 'none';
};
//表单的头名称
document.title,可改,可做变化,不啰嗦了
//整个表单只读
document.body.disabled = true;
这个灰掉了,有点难看,但是网上给出的灰掉这个表单的方法太麻烦,作用一样,简单何乐而不为
唯一缺陷,iframe里的关联视图是怎么也灰不掉的,请高手指点
//隐藏isv的buttion
var liBtns = window.document.getElementsByTagName("LI");
for(var i = 0; i < liBtns.length; i++)
{
if( liBtns[i].id == "_MBcrmFormSubmitCrmForm59truetruefalse"||
liBtns[i].action == "crmForm.Print();"||
liBtns[i].id =="action")
liBtns[i].style.display = "none";
}
可用id,可用action,可用alt,估计样式也可以改,用ietoolbar可以抓到
数据验证错误后定位,不刷新表单
一定要:
crmForm.all.字段名.SetFocus();
event.returnValue = false;
return false;
隐藏左侧菜单,去掉关联视图的button,等常见方法网上都有,不多说了
Changing the label of a field at runtime
crmForm.all.revenue_c.innerText = "Amount Euro";
强烈建议杜杜增加MSCRM板块 Microsoft Dynamics CRM
浙公网安备 33010602011771号