web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Microsoft.Dynamics.Nav.Runtime.NavXmlNode to Microsoft.Dynamics.Nav.Runtime.NavXmlElement.

(3) ShareShare
ReportReport
Posted on by 72
I have the same question (0)
  • KK-20050817-0 Profile Picture
    72 on at

    Unable to convert from Microsoft.Dynamics.Nav.Runtime.NavXmlNode to Microsoft.Dynamics.Nav.Runtime.NavXmlElement.
    give me syntax suggested correction, 
  • Suggested answer
    DAnny3211 Profile Picture
    11,397 on at
     

    Hi,

    Your code snippet for iterating over XML attributes to extract currency and rate looks solid overall. However, there are a few syntax and logic issues that may need attention:

    Suggestions:

    1. Syntax Correction:

      • The line if EvaluateRate, xmlAttr.Value) seems to have a typo. It should likely be:
     
    if Evaluate(Rate, xmlAttr.Value) then
    1. Variable Initialization:

      • Ensure TargetCurrency and Rate are properly declared and initialized before use.
    2. Currency Check Logic:

      • The condition TargetCurrencies.Contains(TargetCurrency) assumes TargetCurrencies is a collection. Make sure it's defined as such (e.g., a List or temporary table).
    3. CurrencyExchangeRate Handling:

      • The CurrencyExchangeRate.Get(...) call should be wrapped in a conditional block to avoid errors if the record doesn’t exist.

    Cleaned-up Version:

     
    for i := 1 to xmlAttrCol.Count do begin
        if xmlAttrCol.Get(i, xmlAttr) then begin
            if xmlAttr.Name = 'currency' then
                TargetCurrency := xmlAttr.Value;
     
            if xmlAttr.Name = 'rate' then
                if Evaluate(Rate, xmlAttr.Value) then begin
                    if TargetCurrencies.Contains(TargetCurrency) then begin
                        if CurrencyExchangeRate.Get('EUR', TargetCurrency, Today) then begin
                            CurrencyExchangeRate.Validate('Exchange Rate Amount', Rate);
                            CurrencyExchangeRate.Modify();
                        end else begin
                            CurrencyExchangeRate.Init();
                            CurrencyExchangeRate.Validate('Currency Code', TargetCurrency);
                            CurrencyExchangeRate.Validate('Starting Date', Today);

    Let me know if you'd like help testing or extending this logic!

    Best regards,
    Daniele

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,092

#2
YUN ZHU Profile Picture

YUN ZHU 663 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 515

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans