I have two lead forms created. One for Office Furniture Product Line and the other for Home Furniture Product line. Now, I've a field set as option type with values Office Furniture and Home Furniture. When the user chooses Home Furniture Lead Form, the form must be able to set Home Furniture as a static value and read-only. Similarly, If it is Office Furniture lead form, the Office Furniture must be set up as a static value read-only. In a way, We want to take away the editing capability for this field from the user. I'm facing a challenge here because the same field is referenced in both the forms. If I set Home Furniture as default value and make it read-only, the office furniture lead form also displays the same value. If anyone could help me with a script to assign 2 different values based on Lead form selection, it'd be a great help.
问问题
2048 次
2 回答
1
我能够通过这个来显示结果。但是我为每种形式编写了两个不同的函数
function HomeFurniture() {
Xrm.Page.getAttribute("new_lineofbusiness").setValue(100000000);
}
在另一种形式上,我插入了相同的功能
function OfficeFurniture() {
Xrm.Page.getAttribute("new_lineofbusiness").setValue(100000000);
}
于 2013-04-19T07:58:35.100 回答
0
您需要检查您是哪种形式并设置字段,您可以从以下示例开始:
var currentForm = Xrm.Page.ui.formSelector.getCurrentItem();
if (currentForm != null) {
var formValue = null;
var currentFormLabel = currentForm.getLabel();
switch (currentFormLabel) {
case "Office Furniture":
formValue = 1;
break;
case "Home Furniture":
formValue = 2;
break;
}
if (formValue != null) {
Xrm.Page.getAttribute("new_formtype").setValue(formValue);
Xrm.Page.getAttribute("new_formtype").setSubmitMode("always");
Xrm.Page.getControl("new_formtype").setDisabled(true);
}
}
当然,仅此代码是不够的,当用户更改表单(如果您想保留这种可能性)或使用导航方法自动更改表单时,您需要小心。
我建议这篇 msdn 文章会有所帮助:
于 2013-04-18T18:58:42.227 回答