javascript 检查字段是否有值
javascript to check if a field has a value
如果它没有价值就做一件事,否则就做另一件事。请参阅下面的代码。这目前不起作用。我很确定我的 if 语句不正确但不确定如何修复
if(new_steponecontractrecieved)
{
Xrm.Page.getAttribute("new_totalamountcollected").setValue(item2);
} else
{
Xrm.Page.getAttribute("new_totalamountcollected").setValue(item1+item2);
}
请尝试以下代码:
var new_steponecontractrecieved= Xrm.Page.getAttribute("new_steponecontractrecieved");
if(new_steponecontractrecieved!=null && new_steponecontractrecieved.getValue()!=null)
{
//have a value do one thing
}
else if(new_steponecontractrecieved!=null)
{
//does not have a value do other thing
}
如果它没有价值就做一件事,否则就做另一件事。请参阅下面的代码。这目前不起作用。我很确定我的 if 语句不正确但不确定如何修复
if(new_steponecontractrecieved)
{
Xrm.Page.getAttribute("new_totalamountcollected").setValue(item2);
} else
{
Xrm.Page.getAttribute("new_totalamountcollected").setValue(item1+item2);
}
请尝试以下代码:
var new_steponecontractrecieved= Xrm.Page.getAttribute("new_steponecontractrecieved");
if(new_steponecontractrecieved!=null && new_steponecontractrecieved.getValue()!=null)
{
//have a value do one thing
}
else if(new_steponecontractrecieved!=null)
{
//does not have a value do other thing
}