CRM 4 Javascript Error: A currency is required if a value exists in a money field

How to use money type of attribute as a lookup in CRM 4.0

Sometimes we need to load a value in an attribute of type money on CRM form using JavasScript

Usually we can use script below to assign values

crmForm.all.myfieldname.DataValue = 100;

But in above case a typical error gets thrown that a currency is required in a money field.

Easiest option to solve this problem is use code below to assign data

crmForm.all.mymoneyfield.CurrencySymbol= ‘£’; //currency symbol

crmForm.all. mymoneyfield.DataValue =99999; //amount

Above code should be enough to solve your issue….

In some cases if you have multiple currencies then you can find the one you need and get the symbol and then assign it

var currency = crmForm.all.transactioncurrencyid;

if (currency == null)


var lookupData = new Array();

var lookupItem = new Object();

GetCurrency(); // write a small function to fetch your currency and then assign values to your global variables = currencyId; = currencyName;

lookupItem.typename = ‘transactioncurrency’;

lookupData[0] = lookupItem;

currency.DataValue = lookupData;


A sample query to fetch currencies – you can modify it as required

var xml = “” +

“<?xml version=\”1.0\” encoding=\”utf-8\”?>” +

“<soap:Envelope xmlns:soap=\”\” xmlns:xsi=\”\” xmlns:xsd=\”\”>” +

GenerateAuthenticationHeader() +

” <soap:Body>” +

” <RetrieveMultiple xmlns=\”\”>” +

” <query xmlns:q1=\”\” xsi:type=\”q1:QueryExpression\”>” +

” <q1:EntityName>transactioncurrency</q1:EntityName>” +

” <q1:ColumnSet xsi:type=\”q1:ColumnSet\”>” +

” <q1:Attributes>” +

” <q1:Attribute>transactioncurrencyid</q1:Attribute>” +

” <q1:Attribute>currencysymbol</q1:Attribute>” +

” <q1:Attribute>currencyname</q1:Attribute>” +

” </q1:Attributes>” +

” </q1:ColumnSet>” +

” <q1:Distinct>false</q1:Distinct>” +

” </query>” +

” </RetrieveMultiple>” +

” </soap:Body>” +

“</soap:Envelope>” +


// make Web Service call

var xmlHttpRequest = new ActiveXObject(“Msxml2.XMLHTTP”);

xmlHttpRequest.Open(“POST”, “/mscrmservices/2007/CrmService.asmx”, false);

xmlHttpRequest.setRequestHeader(“SOAPAction”, “”);

xmlHttpRequest.setRequestHeader(“Content-Type”, “text/xml; charset=utf-8”);

xmlHttpRequest.setRequestHeader(“Content-Length”, xml.length);


// catch return from Web Service

var resultXml = xmlHttpRequest.responseXML;

var entityNodes = resultXml.selectNodes(“//RetrieveMultipleRe

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>