无法使用 js crm 2016 清除查找值
Unable to clear a lookup value using js crm 2016
我正在使用 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){
我正在使用 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){