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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

Evaluate to Decimal Problems Due to XML Format (Problem with Decimal Separators in E-Document App)

(1) ShareShare
ReportReport
Posted on by 12

Hello,

In my country, users use the Romanian number format, which means that we use a comma (,) as a decimal separator and a dot (.) as a thousand separator. We, as a company, developed a solution for E-Invoicing based on the E-Document Core app provided by Microsoft, and we have encountered some issues with decimal and thousand separators when importing invoices from an XML file.

The flow is as follows:

  1. In the XML file, the Cost is 1000.00 (meaning one thousand).
  2. At some point in the code, a RecordRef is created for a Purchase Line (not saved in the database), and it stores 1.000 in the "Direct Unit Cost" field (meaning one thousand).
  3. Later on, the value from that RecordRef is copied to another RecordRef, and this one is saved in the database. To do this, the value from the first RecordRef is passed as a Text to a procedure and then evaluated to a Decimal. However, due to the regional settings (Romania) and the fact that the Evaluate function uses the XMLformat parameter, the value 1.000 (meaning one thousand) is incorrectly evaluated to 1 (one).

I have attached a PDF file with some screenshots from a debug session.

Do you have any ideas on how to solve this problem?

One last thing: if the XML file contained 1000.23, then everything would have worked fine because the RecordRef would have stored 1.000,23, and somehow the Evaluate function would correctly identify the decimal separator and the thousand separator.

Any help would be appreciated!

I have the same question (0)
  • Yi Yong Profile Picture
    2,736 Super User 2026 Season 1 on at
    Hello,
     
    Do you think you can show us what is the debug value after the yellow function?
     
  • GI-28081351-0 Profile Picture
    12 on at
    Hello @Yi Yong,
     
    This are the steps:
     
     
    The values after the first Evaluate (Evaluate(DecimalValue, Value)):
     
     
    The values after the second Evaluate (Evaluate(DecimalValue, Value, XMLFormat())), where the procedure XMLFormat returns 9 :
     
     
    local procedure RoundDecimalValue:
     
     
     
     
    Back to local procedure EvaluateValueToDecimal:
     
     
  • Suggested answer
    Yi Yong Profile Picture
    2,736 Super User 2026 Season 1 on at
    Hello,
     
    Thanks for the information, looks like getting around this might be tricky.
     
    Can you try to subscribe to the event OnBeforeRoundDecimalValue(DecimalFieldRef, DecimalValue, ShouldRound)?
    If the DecimalValue = 1 then you will multiply it by 1000.
  • GI-28081351-0 Profile Picture
    12 on at

    Hello @Yi Yong,

    Unfortunately, I cannot do that because there are cases where the DecimalValue should be 1 (for example, when the Quantity is 1 and the Direct Unit Cost is 1.000). I cannot determine whether the DecimalValue should remain 1 or be 1.000. If I had the original number/text in OnBeforeRoundDecimalValue(DecimalFieldRef, DecimalValue, ShouldRound), then I would have known which one is the correct value.

    Any ideas? Thanks for your help anyway! :)

  • Suggested answer
    Yi Yong Profile Picture
    2,736 Super User 2026 Season 1 on at
    Hello,
     
    Yes, it will be helpful if the original text value is part of the parameter.
     
    I have no idea how the E-Document codeunit works so I am unsure if my suggestion is feasible.
     
    Could you create a boolean field on the purchase line and set it to true if the amount is 1.000 (one thousand) when you run the E-Document Codeunit?
    If that is possible, then you can easily do a conditional rule and apply the formula.
     
     
     
  • GL-17061447-0 Profile Picture
    2 on at
    Hello,
     
    I have the same problem, did you find a work around or maybe there is a fix somewhere ?
    On my side i use the e-document version 25.0.23364.24925
     
    Edit:
    on my side i fixed the problem by using EvenSubscriber and SingleInstance codeunit:

    codeunit 70606 "Be1 PEP Subscribers Single Ins"
    {
        SingleInstance = true;
        [EventSubscriber(ObjectType::Codeunit, Codeunit::"E-Document Create Purch. Doc.", 'OnCreateNewPurchLineOnBeforeRecRefInsert', '', true, true)]
        local procedure OnCreateNewPurchLineOnBeforeRecRefInsert(var EDocument: Record "E-Document"; var TempDocumentHeader: RecordRef; var DocumentHeader: RecordRef; var TempDocumentLine: RecordRef; var DocumentLine: RecordRef);
        var
            PurchaseLine: record "Purchase Line";
        begin
            TempDocumentLine.SetTable(PurchaseLine);
            MyDirectUnitCost := PurchaseLine."Direct Unit Cost";
        end;

        [EventSubscriber(ObjectType::Codeunit, Codeunit::"E-Document Create Purch. Doc.", 'OnBeforeProcessLineFieldsAssignment', '', true, true)]
        local procedure OnBeforeProcessLineFieldsAssignment(var DocumentHeader: RecordRef; var DocumentLine: RecordRef; var PurchaseField: Record Field);
        var
            PurchaseLine: record "Purchase Line";
            DirectUnitCostRef: FieldRef;
        begin
            DocumentLine.SetTable(PurchaseLine);
            If PurchaseLine."Direct Unit Cost" <> MyDirectUnitCost then begin
                DirectUnitCostRef := DocumentLine.Field(22);  // Purchase Line. Direct unit Cost
                DirectUnitCostRef.Value := MyDirectUnitCost;
                DirectUnitCostRef.Validate();
            end;
        end;

        var
            MyDirectUnitCost: decimal;
    }

    Best Regards.
     

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,344 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,742 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,231

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans