开发者

How to set a control's DataValue to a number in MS Dyanamics CRM 4.0?

开发者 https://www.devze.com 2022-12-24 19:32 出处:网络
I need to set the value of a field in a form via JavaScript. The source of the data is from another source, via an IFRAME.I\'m running this code in the onload of the ASPX page in the IFRAME:

I need to set the value of a field in a form via JavaScript. The source of the data is from another source, via an IFRAME. I'm running this code in the onload of the ASPX page in the IFRAME:

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

// Convert that value to a number, stripping out non-number cha开发者_StackOverflow社区racters.
var currencyNumber = new Number(currencyText.replace(/[^0-9\.]+/g,""));

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

When I do this I get an message "This control only accepts numbers or null as input". What is the acceptable way to load a value into a currency field in MS CRM?


Try this instead

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号