表单上的按钮不通过所有 JS

Button on Form Not going through all JS

我已将按钮形状的网络资源添加到我们的 CRM 在线实例中的表单上。我已经调试了一段时间了,但我不明白我在这里遗漏了什么。

下面是网络资源(出于显而易见的原因,我省略了 javascript URL)

<html>
<head>
<link rel="stylesheet" 
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" 
integrity="sha384-
BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" 
crossorigin="anonymous">
</head>
<body>
<button onclick="TriggerNPS()" class=".btn-default">
<i class="glyphicon glyphicon-check"></i>
Send NPS Now
</button>
<script src="Javascript URL" type="text/javascript"></script>
</body>
</html>

Javascript URL 链接到

function TriggerNPS() {
var NoTick = parent.Xrm.Page.getAttribute("ondemandnps").getValue();
if ((NoTick) ==null);
  parent.Xrm.Page.getAttribute("ondemandnps").setValue("1");
  parent.Xrm.Page.data.entity.save();
    return
if ((NoTick) !=null)
  parent.Xrm.Page.getAttribute("ondemandnps").setValue("0");
  parent.Xrm.Page.data.entity.save();
    return;

}

我看到的是,如果它正在查看的字段(勾选框)包含数据,那么确保它会去除抽动。但是如果盒子是空的。我无法获取添加支票的脚本。尽管该命令确实有效,但在控制台中对此进行了测试。它越过界线并且没有越界,但什么也不做。

如有任何帮助,我们将不胜感激。

也许试试这个:

function TriggerNPS() {
    var NoTick = parent.Xrm.Page.getAttribute("ondemandnps").getValue();
    if (NoTick == null) {
        parent.Xrm.Page.getAttribute("ondemandnps").setValue(true);
    }
    else {
      parent.Xrm.Page.getAttribute("ondemandnps").setValue(false);
    }
    parent.Xrm.Page.data.entity.save();
}