我需要从我的表单上的标签中获取所有控件,我尝试使用我在网上找到的这个选项但是它没有任何想法吗?
var tabs = Xrm.Page.ui.tabs.get();
var fieldList = new Array();
for (var i in tabs)
{
var tab = tabs[i];
if(tab.getName() == "tab_2")
{
tab.sections.forEach(function (section, sectionIndex)
{
section.controls.forEach(function (control, controlIndex)
{
switch (control.getControlType())
{
case "standard":
case "lookup":
case "optionset":
var attribute = control.getAttribute();
if (attribute != null)
{
fieldList.push(attribute.getName());
}
break;
}
});
});
}
}
}
答案 0 :(得分:0)
我刚刚尝试了代码并且它有效。
它会查找名为 tab_2 的标签,然后获取该标签中的所有控件,并将control.name
添加到数组(fieldList
)
结果是一个简单的控件名称数组。当我在我的联系表单上运行它时(调整了Tab Name
),我得到了以下结果:
[
"fullname",
"nickname",
"employeeid",
"jobtitle",
"parentcustomerid",
"emailaddress1",
"telephone2",
"telephone1",
"mobilephone",
"fax",
"address1_composite",
"preferredsystemuserid",
"familystatuscode",
"spousesname",
"birthdate",
"description",
"ownerid",
"createdon"
]
如果这不适合你,我建议如下: