【问题标题】:Auto-Populate Field using Javascript使用 Javascript 自动填充字段
【发布时间】:2015-10-07 17:22:31
【问题描述】:

我创建了这个 javascript 来自动填充一个字段,其中包含来自其他字段的值。它以 onSave 事件的形式调用。

function OppTopic() {

var products = "";


var parent = Xrm.Page.getAttribute("parentaccountid").getvalue();
var city = Xrm.Page.getAttribute("address1_city").getValue();
var automation = Xrm.Page.getAttribute("new_automationfeatures").getValue();
var service = Xrm.Page.getAttribute("new_service").getValue();

//Determines if a Product/Service is selected   


if (automation == true) {//***AUTOMATION***
    if (products != ""){
    products += ",Automation";
    }
    else{
    products = "Automation";       
    }
}

if (service == true) {//***SERVICE***

    if (products != "")
        products += ",Service";
    else
        products = "Service";
}

if (automation == false && service == false) {

    products = "null";
}


var subject = parent + " - " + city + " - " + products; 
Xrm.Page.getAttribute("name").setValue(subject);

}

但是,当表单被保存时,这是出现的错误。我不确定这个错误是什么意思?

我检查了字段名称,它们是正确的。 导致此错误的问题可能是什么?

谢谢

【问题讨论】:

  • 在哪里获得父级的值,getvalue();有不正确的情况。 (应该是得到Value())
  • 解决这个问题的最佳方法是逐步完成代码和调试。
  • 也有可能是你的函数被错误调用或者没有被正确实例化。所有错误都是说您的 onsave 事件函数之一存在错误。

标签: javascript dynamics-crm-2015 auto-populate


【解决方案1】:

var parent 将返回一个作为 CRM 查找的 javascript 对象。如果您将它与其他字符串放在一个字符串中,则必须从您尝试添加的查找中检索名称或任何其他属性

    var parentName = "";
    var parent = new Array();
    parent = Xrm.Page.getAttribute("parentaccountid").getValue();
    if(parent!=null){ 
        parentName = parent[0].name;
    }

来源:http://www.mscrmconsultant.com/2012/08/get-and-set-lookup-value-using.html

【讨论】:

    猜你喜欢
    • 2013-04-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-29
    相关资源
    最近更新 更多