问题描述
有没有办法确定该部分是否为CRM表格中的标题?
Is there a way to tell if the section is a header in CRM Form?
我们正在使用Microsoft Dynamics CRM 2016,我要求在满足特定条件时禁用联系人"表单上的所有字段.我正在使用下面的代码,到目前为止,该代码正在运行.
We're on Microsoft Dynamics CRM 2016 and I have a requirement to disable all fields on the Contact form when a certain condition is met. I'm using the code below and so far the code is working.
var attributes = Xrm.Page.data.entity.attributes.get();
for (var i in attributes) {
var myattribute = Xrm.Page.data.entity.attributes.get(attributes[i].getName());
var myname = myattribute.getName();
if (Xrm.Page.getControl(myname) != null) {
//alert(myname);
Xrm.Page.getControl(myname).setDisabled(true);
}
}
不过我问的原因(对于标头字段而言特别),您需要在字段名称前放置 header _
才能获得标头字段.例如 header_name
.由于我们的CRM管理器喜欢在标题上放置不同的字段,因此最好自动禁用标题字段,而不是手动更改标题字段.
However the reason I ask, special for header fields, you need to put header_
before the field name in order to get to the header fields. For example header_name
. Since our CRM Manager likes to put different fields on the header, it'd be nice to automatically disable the header fields instead of manually change it.
有没有办法确定该部分是否为CRM表格中的标题?
Is there a way to tell if the section is a header in CRM Form?
推荐答案
基本上,表单中的每个字段都必须位于节
中,但 header
除外.因此,在这种情况下这很有用,因为我们必须标识 header
&中的字段禁用它.
Basically every field in the form has to be in a section
except header
. So this is helpful in this case as we have to identify the fields in header
& disable it.
我已经使用了 forEach
迭代器来检查每个控件,并且如果该控件没有作为 section
的Parent,那么它在 header
,因此请禁用该控件.
I have used forEach
iterator to check each control and if that control does not have a Parent which is a section
- then its a control in header
, so disable the control.
Xrm.Page.ui.controls.forEach(function (control) {
if(!control.getParent()){
control.setDisabled(true);
}
});
参考: getParent
这篇关于如何在CRM表单中识别标题部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!