locked
Auto Update Exchange Rate RRS feed

  • Question

  • Hello all,

    I know that you can just add a new currency to CRM 4.0 and manually enter the exchange rate with base currency as US Dollar.
    Is there any way to automatically have this rate updated every morning, or on a regular basis?

    Much appreciated.
    Wednesday, April 29, 2009 3:04 PM

Answers

  • hi found this maybe it will guide you in the right direction

    var currency = crmForm.all.transactioncurrencyid;
    var estval = crmForm.all.estimatedvalue;
    var desc = crmForm.all.description;

    var serverUrl = "http://www.webservicex.net";

    var startTag = "<double xmlns=\"http://www.webserviceX.NET/\">";
    var endTag = "</double>";
    var exch = "";
    var valueStart = "";
    var valueEnd = "";

    var i=0;
    var j=0;
    var k=0;
    var r=0;

    // Looks up Currency Name of Currency GUID
    //
    var lookupItem = new Array;

    // This will get the lookup for the attribute transactioncurrencyid on the Account form
    //
    lookupItem = currency.DataValue;

    // Switch to convert Currency Name to ISO Currency Code
    //
    switch (lookupItem[0].name) {
      case "Danish krone":
      i = "DKK";
      break;

      case "New Zealand Dollar":
      i = "NZD";
      break;

      case "Philippine Peso":
      i = "PHP";
      break;

      case "US Dollar":
      i = "USD";
      break;
    }

    var xmlhttp = new ActiveXObject(”Microsoft.XMLHTTP”);
    xmlhttp.open("GET", "
    http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=PHP&ToCurrency=" + escape(i), false);
    xmlhttp.send();

    valueStart = xmlhttp.responseXML.xml.indexOf(startTag, valueEnd) + startTag.length;
    valueEnd = xmlhttp.responseXml.xml.indexOf(endTag, valueEnd+1);
    exch = xmlhttp.responseXML.xml.substring(valueStart, valueEnd);

    // Set the exchange rate on the custom attribute.
    crmForm.all.exchangerate.DataValue = parseFloat(exch);

    // TEST PRINT!!!!!!!!!!!!!!! DELETE THIS!!!!
    //
    desc.DataValue = i;

    http://blogs.msdn.com/arash/archive/2006/02/01/521565.aspx?CommentPosted=true#commentmessage

    http://msdn.microsoft.com/en-us/library/aa679987.aspx


    Tiaan van Niekerk http://crmdelacreme.blogspot.com Skype:tiaan.van.niekerk1
    Thursday, April 30, 2009 3:36 AM
  • Hi Jacob,

    you have to develop a custom solution for this.

    If you have a web service based provider for such information, this would take a day for an experience developer to write an appropriate windows service to update CRM automatically.

    Best regards,
    Jürgen
    Jürgen Beck

    Dipl. Kfm./Wirtschaftsinformatik
    MVP, MCSD.NET, MCITP DBA, MCDBA, MCSE
    Microsoft Certified Business Management Solutions Professional
    Microsoft Certified CRM Developer
    Microsoft Certified Trainer

    ComBeck IT Services & Business Solutions
    Microsoft Gold Certified Partner
    Microsoft Small Business Specialist

    Developing & Supporting Business Applications from small business to big enterprises covering scores of sectors

    http://www.combeck.de
    Wednesday, April 29, 2009 3:07 PM
    Moderator

All replies

  • Hi Jacob,

    you have to develop a custom solution for this.

    If you have a web service based provider for such information, this would take a day for an experience developer to write an appropriate windows service to update CRM automatically.

    Best regards,
    Jürgen
    Jürgen Beck

    Dipl. Kfm./Wirtschaftsinformatik
    MVP, MCSD.NET, MCITP DBA, MCDBA, MCSE
    Microsoft Certified Business Management Solutions Professional
    Microsoft Certified CRM Developer
    Microsoft Certified Trainer

    ComBeck IT Services & Business Solutions
    Microsoft Gold Certified Partner
    Microsoft Small Business Specialist

    Developing & Supporting Business Applications from small business to big enterprises covering scores of sectors

    http://www.combeck.de
    Wednesday, April 29, 2009 3:07 PM
    Moderator
  • hi found this maybe it will guide you in the right direction

    var currency = crmForm.all.transactioncurrencyid;
    var estval = crmForm.all.estimatedvalue;
    var desc = crmForm.all.description;

    var serverUrl = "http://www.webservicex.net";

    var startTag = "<double xmlns=\"http://www.webserviceX.NET/\">";
    var endTag = "</double>";
    var exch = "";
    var valueStart = "";
    var valueEnd = "";

    var i=0;
    var j=0;
    var k=0;
    var r=0;

    // Looks up Currency Name of Currency GUID
    //
    var lookupItem = new Array;

    // This will get the lookup for the attribute transactioncurrencyid on the Account form
    //
    lookupItem = currency.DataValue;

    // Switch to convert Currency Name to ISO Currency Code
    //
    switch (lookupItem[0].name) {
      case "Danish krone":
      i = "DKK";
      break;

      case "New Zealand Dollar":
      i = "NZD";
      break;

      case "Philippine Peso":
      i = "PHP";
      break;

      case "US Dollar":
      i = "USD";
      break;
    }

    var xmlhttp = new ActiveXObject(”Microsoft.XMLHTTP”);
    xmlhttp.open("GET", "
    http://www.webservicex.net/CurrencyConvertor.asmx/ConversionRate?FromCurrency=PHP&ToCurrency=" + escape(i), false);
    xmlhttp.send();

    valueStart = xmlhttp.responseXML.xml.indexOf(startTag, valueEnd) + startTag.length;
    valueEnd = xmlhttp.responseXml.xml.indexOf(endTag, valueEnd+1);
    exch = xmlhttp.responseXML.xml.substring(valueStart, valueEnd);

    // Set the exchange rate on the custom attribute.
    crmForm.all.exchangerate.DataValue = parseFloat(exch);

    // TEST PRINT!!!!!!!!!!!!!!! DELETE THIS!!!!
    //
    desc.DataValue = i;

    http://blogs.msdn.com/arash/archive/2006/02/01/521565.aspx?CommentPosted=true#commentmessage

    http://msdn.microsoft.com/en-us/library/aa679987.aspx


    Tiaan van Niekerk http://crmdelacreme.blogspot.com Skype:tiaan.van.niekerk1
    Thursday, April 30, 2009 3:36 AM
  • Tiaan, this is nice! I implemented the same using the US Federal Reserve Web Service, but some of the commercial services must have complained because they discontinued it last month (see: http://www.newyorkfed.org/markets/pilotfx.html and http://www.newyorkfed.org/newsevents/news/markets/2008/an081222.html).

    No kind words come to my mind to comment the decision to discontinue a public service (not that they did not have to spend money to implement it). The topping is that they discontinued the service "given the availability of alternative market-based sources for these rates". In other words, sorry guys, we found out that there are people out there who charge for this service, it's in everybody's best interest if we stop giving it out for free.

    There is another public service that I've been using (from the ECB) for some European rates, but it's not a proper Web Service: http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml

    However this WebserviceX seems working well, and it looks like it's free. Is it?
    Thursday, April 30, 2009 6:41 AM
  • Hi Tiaan,

    Did you manage to make this work? I have used the same code at CRM 4.0 Opportunity form, Currency field OnChange event. So Am I suppose to see the currency rate updated automatically at the Setting -> Business Management -> Currencies?

    The currency rate remain the same. Is there any setting or configuration steps that I have overlooked?

    Thanks a lot.

    Friday, June 26, 2009 4:15 AM
  • Sorry, just realized that the sample code is to update the estimated value and has nothing to do with the currency update at  Setting -> Business Management -> Currencies.

    Is there any way to update the currency rate? Is writting a windows services the only way as suggested by Jürgen?

    Any help would be appreciated, thanks in advance.
    Friday, June 26, 2009 4:52 AM