我正在使用Dynamics crm 2016,在onChange事件之后,我调用了一个函数来检查一些术语,并根据这些术语清除查找字段。 问题是查找不清楚...我的代码中的问题在哪里?
function preventSavinf3940category(){
if(Xrm.Page.getAttribute("new_activitycategory1id") == null){ // this if is false even after setValue to null
return;
}
var category1 = Xrm.Page.getAttribute("new_activitycategory1id").getValue();
var category1Data = category1[0].id;
var students = getId(1);
var teachers = getId(2);
if(category1Data == teachers || category1Data== students)
{
Xrm.Page.getAttribute("new_activitycategory1id").setValue(null);- doesn't clear the field
alert("this category is not in use anymore")
}
}
更改下面的行
if(Xrm.Page.getAttribute("new_activitycategory1id") == null){ // this if is false even after setValue to null
喜欢这个
if(Xrm.Page.getAttribute("new_activitycategory1id") != null && Xrm.Page.getAttribute("new_activitycategory1id").getValue() == null){