Get exchange rate from web in to MS AX
static void
GetExchangeRates(Args _args)
{
com com = new com('microsoft.xmlhttp');
com com1;
XMLDocument xmlDoc;
Dialog exchDialog = new
Dialog("Exchange Rates");
DialogField fromField;
DialogField ToField;
str url;
;
fromField =
exchDialog.addField(typeid(currencycode), 'Base Currency');
fromField.value(CompanyInfo::find().CurrencyCode);
ToField =
exchDialog.addField(typeid(currencycode), 'To Currency');
if(exchDialog.run())
{
url =
"http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?";
url += "FromCurrency="
+strupr(fromField.value())+"&ToCurrency="+strupr(ToField.value());
com.open("get",url, false);
com.send();
com1 = com.responsexml();
xmlDoc =
XmlDocument::newXml(com1.xml());
info("1"+fromField.value() +
" = " +xmlDoc.getNamedElement('double').text() + " "
+ToField.value());
}
}
Leave a Comment