0
我正在使用CRM,并且需要使用JavaScript锁定所有字段(大约300)。XRM SetDisable每次都不起作用
我用这个函数:
var allAttributes = Xrm.Page.data.entity.attributes.get();
for (var i in allAttributes) {
var myattribute = Xrm.Page.data.entity.attributes.get(allAttributes[i].getName());
if (myattribute != null && myattribute != undefined && myattribute != '') {
var myname = myattribute.getName();
var myControl = Xrm.Page.getControl(myname);
if (myControl != null && myControl != undefined && myControl != '')
myControl.setDisabled(true);
}
}
对大部分孩子来说,它的工作原理,但某些领域仍处于我的表单编辑。 我一步一步在Chrome中调试它,看起来,在我的函数后没有锁定的字段上,我做了“myControl.getDisabled()
”,并且它被设置为true。但该字段不锁定在表单上。
这些字段上没有任何其他JavaScript正在运行。我试图延迟10秒(使用setTimeout)我的函数调用,没有任何改变。
任何想法如何锁定每个领域?
你的代码会抛出错误,因为并不是所有的控件都有setDisabled方法。示例 - IFrames,子网格和webresources。 –
为了使这段代码正常工作,你可以添加一行if(typeof controls [i] .setDisabled!=“undefined”) –
@Andrii Butenko感谢您的评论,我没有测试它的IFrames,但是对于webresources和子网格它不会抛出错误,也许汇总和CRM版本?我正在研究CRM 2011. – Sxntk