admin管理员组文章数量:1353235
I have two fields : Cobertura and other 3 (lets call it x,y,z) If cobertura value is 150 or 160 I need to make the other 3 fields required and not allowed to save before fill these field, using java script in CRM 11. Using set required level will work for me? What exactly this function does?
I have two fields : Cobertura and other 3 (lets call it x,y,z) If cobertura value is 150 or 160 I need to make the other 3 fields required and not allowed to save before fill these field, using java script in CRM 11. Using set required level will work for me? What exactly this function does?
Share Improve this question asked Apr 20, 2015 at 14:02 Debborah CamargoDebborah Camargo 211 gold badge1 silver badge4 bronze badges3 Answers
Reset to default 5Yes, the setRequiredLevel
function will work in your case. The function changes the requirement level of the field (possible values are none
, remended
, required
)
you need to check the Cobertura value inside OnLoad
and OnChange
event:
var cobertura = Xrm.Page.getAttribute("cobertura").getValue();
if (cobertura == 150 || cobertura == 160) {
Xrm.Page.getAttribute("x").setRequiredLevel("required");
Xrm.Page.getAttribute("y").setRequiredLevel("required");
Xrm.Page.getAttribute("z").setRequiredLevel("required");
} else {
Xrm.Page.getAttribute("x").setRequiredLevel("none");
Xrm.Page.getAttribute("y").setRequiredLevel("none");
Xrm.Page.getAttribute("z").setRequiredLevel("none");
}
Essentially the same as Guido's just refactored
function coberturaSetRequired()
{
var cobertura = Xrm.Page.getAttribute("cobertura");
var x = Xrm.Page.getAttribute("x");
var y = Xrm.Page.getAttribute("y");
var z = Xrm.Page.getAttribute("z");
var isRequired = "none";
if (!cobertura) return;
if (cobertura.getValue() == 150 || cobertura.getValue() == 160)
{
isRequired = "required";
}
x.setRequiredLevel(isRequired);
y.setRequiredLevel(isRequired);
z.setRequiredLevel(isRequired);
}
Function setRequiredLevel("required")
makes the data attribute required. The label of every control field on the web form displaying the attribute will get an asterisk (*) appended to the label text. The user will not be able to save the data on the form as long as the attribute remains empty.
本文标签: javascriptSetRequiredLevel How it worksStack Overflow
版权声明:本文标题:javascript - SetRequiredLevel How it works? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743903935a2559177.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论