Currency exchange rates are updated incorrectly when you integrate Microsoft Dynamics CRM with Microsoft Dynamics NAV 2009 R2 by using the Connector for Microsoft Dynamics

Article translations Article translations
Article ID: 2597312 - View products that this article applies to.
This article applies to Microsoft Dynamics NAV for all countries and all language locales.
Expand all | Collapse all

On This Page

SYMPTOMS

Assume that you integrate Microsoft Dynamics CRM with Microsoft Dynamics NAV 2009 R2 by using the Connector for Microsoft Dynamics Feature Pack 5. In certain scenarios, currency exchange rates are updated incorrectly in Microsoft Dynamics CRM.
When you update currency exchange rates in Microsoft Dynamics NAV 2009 R2, you receive the following error message:
[Currency Exchange Rates to Currency] has encountered an error while processing …
TransactionCurrency with ID = <GUID> does not exist.
In this situation, only the first record of the currency exchange rates is synchronized to Microsoft Dynamics CRM. When the system synchronizes subsequent records that are entered into the Currency Exchange Rate table with later start dates, this error occurs.

CAUSE

This problem occurs because the last changed currency exchange rate, instead of the current exchange rate for the particular currency, is synchronized to Microsoft Dynamics CRM by using the Connector for Microsoft Dynamics.

RESOLUTION

Hotfix information

A supported hotfix is now available from Microsoft. However, it is only intended to correct the problem that is described in this article. Apply it only to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next Microsoft Dynamics NAV 2009 service pack or the next Microsoft Dynamics NAV version that contains this hotfix.

Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Technical Support Professional for Microsoft Dynamics and related products determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

Installation information

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.

Note Before you install this hotfix, verify that all Microsoft Navision client users are logged off the system. This includes Microsoft Navision Application Services (NAS) client users. You should be the only client user who is logged on when you implement this hotfix.

To implement this hotfix, you must have a developer license.

We recommend that the user account in the Windows Logins window or in the Database Logins window be assigned the "SUPER" role ID. If the user account cannot be assigned the "SUPER" role ID, you must verify that the user account has the following permissions:
  • The Modify permission for the object that you will be changing.
  • The Execute permission for the System Object ID 5210 object and for the System Object ID 9015 object.


Note You do not have to have rights to the data stores unless you have to perform data repair.

Code changes

Note Always test code fixes in a controlled environment before you apply the fixes to your production computers.
To resolve this problem, follow these steps:
  1. Apply the following code changes in Microsoft Dynamics NAV 2009 R2:
    1. Create a new GetCurrencyFactor function in the Currency Exchange Rate table (330) as follows:
      PROCEDURE GetCurrentCurrencyFactor@14(CurrencyCode@1000 : Code[10]) : Decimal;
          BEGIN
            SETRANGE("Currency Code",CurrencyCode);
            IF FINDLAST THEN
              EXIT("Exchange Rate Amount" / "Relational Exch. Rate Amount")
          END;
    2. Create a new SetCurrencyFactor function in the Currency Exchange Rate table (330) as follows:
      PROCEDURE SetCurrentCurrencyFactor@15(CurrencyCode@1000 : Code[10];CurrencyFactor@1001 : Decimal);
          VAR
            RateForTodayExists@1002 : Boolean;
          BEGIN
            "Currency Code" := CurrencyCode;
            TESTFIELD("Currency Code");
            RateForTodayExists := GET(CurrencyCode,TODAY);
            "Exchange Rate Amount" := 1;
            "Relational Exch. Rate Amount" := 1 / CurrencyFactor;
            "Adjustment Exch. Rate Amount" := "Exchange Rate Amount";
            "Relational Adjmt Exch Rate Amt" := "Relational Exch. Rate Amount";
           IF RateForTodayExists THEN BEGIN
             "Relational Currency Code" := '';
             MODIFY;
           END ELSE BEGIN
             "Starting Date" := TODAY;
             INSERT;
           END;
          END;
    3. Add a new global variable in the Currencies form (5), and then specify the variable as follows:
      • Name: CurrencyFactor
      • Datatype: Decimal
    4. Add the Currency Factor field (46) in the Currencies form (5).
    5. Add a new local variable in the Currency Factor - OnValidate trigger in the Currencies form (5), and then specify the variable as follows:
      • Name: CurrencyExchangeRate
      • DataType: Record
      • Subtype: Currency Exchange Rate
    6. Add the following code in the Currency Factor - OnValidate trigger in the Currencies form (5):
      CurrencyExchangeRate.SetCurrentCurrencyFactor(Code,CurrencyFactor);
    7. Add a new local variable in the OnAfterGetRecord trigger in the Currencies form (5), and then specify the variable as follows:
      • Name: CurrencyExchangeRate
      • DataType: Record
      • Subtype: Currency Exchange Rate
    8. Add the following code in the OnAfterGetRecord trigger in the Currencies form (5):
      CurrencyFactor := CurrencyExchangeRate.GetCurrentCurrencyFactor(Code);
    9. Add a new global variable in the Currencies Page (5), and then specify the variable as follows:
      • Name: CurrencyFactor
      • Datatype: Decimal
    10. Add the Currency Factor field in the Currencies page (5), and then specify the field as follows:
      • Name: CurrencyFactor
      • Caption: Currency Factor
      • Type: Field
      • SourceExpr: CurrencyFactor
    11. Add a new local variable in the Currency Factor - OnValidate trigger in the Currencies page (5), and then specify the variable as follows:
      • Name: CurrencyExchangeRate
      • DataType: Record
      • Subtype: Currency Exchange Rate
    12. Add the following code in the Currency Factor - OnValidate trigger in the Currencies page (5):
      CurrencyExchangeRate.SetCurrentCurrencyFactor(Code,CurrencyFactor);
    13. Add a new local variable in the OnAfterGetRecord trigger in the Currencies page (5), and then specify the variable as follows:
      • Name: CurrencyExchangeRate
      • DataType: Record
      • Subtype: Currency Exchange Rate
    14. Add the following code in the OnAfterGetRecord trigger in the Currencies page (5):
      CurrencyFactor := CurrencyExchangeRate.GetCurrentCurrencyFactor(Code);
    15. Add a new local variable in the UpdateParentIntegrationRecord function in the Integration Management codeunit (5150), and then specify the variable as follows:
      • Name: Currency
      • DataType: Record
      • Subtype: Currency
    16. Change the code in the UpdateParentIntegrationRecord function in the Integration Management codeunit (5150) as follows:
      Existing code
      ...
        DATABASE::"Ship-to Address":
          BEGIN
            FieldRef1 := RecRef.FIELD(1); // "Customer No."
            IF Customer.GET(FieldRef1.VALUE) THEN BEGIN
              ParentRecRef.GETTABLE(Customer);
              InsertUpdateIntegrationRecord(ParentRecRef,TimeStamp);
            END;
          END;
      END;
      Replacement code
      ...
       
        DATABASE::"Ship-to Address":
          BEGIN
            FieldRef1 := RecRef.FIELD(1); // "Customer No."
            IF Customer.GET(FieldRef1.VALUE) THEN BEGIN
              ParentRecRef.GETTABLE(Customer);
              InsertUpdateIntegrationRecord(ParentRecRef,TimeStamp);
            END;
          END;
      
      // Add the following lines.
        DATABASE::"Currency Exchange Rate":
          BEGIN
            FieldRef1 := RecRef.FIELD(1); // "Currency Code"
            IF Currency.GET(FieldRef1.VALUE) THEN BEGIN
              ParentRecRef.GETTABLE(Currency);
              InsertUpdateIntegrationRecord(ParentRecRef,TimeStamp);
            END;
          END;
      // End of the lines.
      
      END;
    17. Change the code in the EnableConnector function in the Integration Management codeunit (5150) as follows:
      Existing code
      ...
      SetupWebServicePages(FORM::"Ship-to Address",DATABASE::"Ship-to Address");
      SetupWebServicePages(FORM::"Contact Card",DATABASE::Contact);
      
      //Delete the following line.
      SetupWebServicePages(FORM::"Currency Exchange Rates",DATABASE::"Currency Exchange Rate");
      
      SetupWebServicePages(FORM::"Customer Disc. Groups",DATABASE::"Customer Discount Group");
      SetupWebServicePages(FORM::"Item Disc. Groups",DATABASE::"Item Discount Group");
      ...
      Replacement code
      ...
      SetupWebServicePages(FORM::"Ship-to Address",DATABASE::"Ship-to Address");
      SetupWebServicePages(FORM::"Contact Card",DATABASE::Contact);
      SetupWebServicePages(FORM::"Customer Disc. Groups",DATABASE::"Customer Discount Group");
      SetupWebServicePages(FORM::"Item Disc. Groups",DATABASE::"Item Discount Group");
      ...
    18. Change the code in the SetupIntegrationTable function in the Integration Management codeunit (5150) as follows:
      Existing code
      ...
      InitializeIntegrationRecords(DATABASE::"Unit of Measure");
      InitializeIntegrationRecords(DATABASE::"Ship-to Address");
      InitializeIntegrationRecords(DATABASE::Contact);
      
      //Delete the following line.
      InitializeIntegrationRecords(DATABASE::"Currency Exchange Rate");
      
      InitializeIntegrationRecords(DATABASE::"Customer Discount Group");
      ...
      Replacement code
      ...
      InitializeIntegrationRecords(DATABASE::"Unit of Measure");
      InitializeIntegrationRecords(DATABASE::"Ship-to Address");
      InitializeIntegrationRecords(DATABASE::Contact);
      InitializeIntegrationRecords(DATABASE::"Customer Discount Group");
      ...
    19. Change the code in the IsIntergrationRecord function in the Integration Management codeunit (5150) as follows:
      Existing code
      ...
      DATABASE::"Unit of Measure",
      DATABASE::"Ship-to Address",
      DATABASE::Contact,
      
      //Delete the following line.
      DATABASE::"Currency Exchange Rate",
      
      DATABASE::"Customer Discount Group",
      ...
      Replacement code
      ...
      DATABASE::"Unit of Measure",
      DATABASE::"Ship-to Address",
      DATABASE::Contact,
      DATABASE::"Customer Discount Group",
      ...
    20. Change the code in the IsIntegrationRecordChild function in the Integration Mangement codeunit (5150) as follows:
      Existing code
      ...
      IF TableID IN
        [DATABASE::"Sales Line",
         DATABASE::"Sales Invoice Line"]
      THEN
        EXIT(TRUE);
      EXIT(FALSE);
      ...
      Replacement code
      ...
      IF TableID IN
        [DATABASE::"Sales Line",
      
         // Add the following line.
         DATABASE::"Currency Exchange Rate",
      
         DATABASE::"Sales Invoice Line"]
      THEN
        EXIT(TRUE);
      EXIT(FALSE);
      ...
  2. Install the Connector for Microsoft Dynamics Feature Pack 6.
    Note After you install the Connector for Microsoft Dynamics Feature Pack 6, you must deactivate the "NAV Currency Exchange Rates to Currency" map in the Connector and import the new "NAV Currencies to Currency" map, rerun the NAV Adapter configuration, and then activate the new map.

Prerequisites

You must have Microsoft Dynamics NAV 2009 R2 installed to apply this hotfix.

Removal information

You cannot remove this hotfix.

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
Note This is a "FAST PUBLISH" article created directly from within the Microsoft support organization. The information contained herein is provided as-is in response to emerging issues. As a result of the speed in making it available, the materials may include typographical errors and may be revised at any time without notice. See Terms of Use for other considerations.

Properties

Article ID: 2597312 - Last Review: August 30, 2011 - Revision: 3.0
APPLIES TO
  • Microsoft Dynamics NAV 2009
Keywords: 
kbqfe kbmbsmigrate kbmbscodefix kberrmsg kbsurveynew KB2597312

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com