【问题标题】:How to set a control's DataValue to a number in MS Dyanamics CRM 4.0?如何在 MS Dynamics CRM 4.0 中将控件的数据值设置为数字?
【发布时间】:2010-03-22 19:53:38
【问题描述】:

我需要通过 JavaScript 在表单中设置字段的值。数据的来源来自另一个来源,通过 IFRAME。我在 IFRAME 的 ASPX 页面的 onload 中运行此代码:

// Get value from source
var currencyText = document.getElementById("contractValue").value;

// Convert that value to a number, stripping out non-number characters.
var currencyNumber = new Number(currencyText.replace(/[^0-9\.]+/g,""));

//  Set the value in the CRM field.
parent.crmForm.all.targetCurrencyField.DataValue = currencyNumber;

当我这样做时,我收到一条消息“此控件只接受数字或 null 作为输入”。将值加载到 MS CRM 中的货币字段的可接受方式是什么?

【问题讨论】:

    标签: javascript dynamics-crm


    【解决方案1】:

    试试这个

    //strip non numeric characters from currencyText
    parent.crmForm.all.targetCurrencyField.DataValue = parseInt(currencyText)
    

    【讨论】:

    • 这行得通,尽管我将其更改为 parseFloat 以确保我获得了美分。知道为什么这有效,但 new Number() 无效吗?
    • 你不想要 new Number() 因为那实际上是在创建一个对象。你可以改用 parent.crmForm.all.targetCurrencyField.DataValue = Number(currencyText)。
    猜你喜欢
    • 2012-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    • 2014-01-11
    • 1970-01-01
    相关资源
    最近更新 更多