Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

Why I can't assing a value to CurrReport.LANGUAGE?

(0) ShareShare
ReportReport
Posted on by 34

I want change the language of a report, before then 22.1 version of BC I use this code

                Lenguaje.SETRANGE(Lenguaje."Abbreviated Name", customer."Language Code");

                IF Lenguaje.FIND('-') THEN begin
                    CurrReport.LANGUAGE := Lenguaje."Language ID";
                end;
This code worked but when BC updated to 22.1 the code not work. CurrReport.LANGUAGE always take te¡he value that my web client language have assigned to it.
 
Example

If I assign to CurrReport.Language the value 1033 which is the code for the English language.
      CurrReport.Language := 1033
When reviewing the value of CurrReport.Language it shows us that the value is 2858 which is Spanish and is the language in which the BC client is configured.
Note: I have also tried to use CurrReport.LANGUAGE := LanguageCodeunit.GetLanguageIdOrDefault(CustomerInfo."LanguageCode").
  • Verified answer
    Fernando Jose R Profile Picture
    Fernando Jose R 34 on at
    Why I can't assing a value to CurrReport.LANGUAGE?
    It seems that it was a BC bug and it has been fixed with the last update.
  • BedrettinQdK Profile Picture
    BedrettinQdK 5 on at
    RE: Why I can't assing a value to CurrReport.LANGUAGE?

    I have the same Problem.

    There is a new Field in Customer page called "Location code", when i fill it with the Code 'ENU', i expect it to print documents for this customer in english, but it doesnt work for me.

    I have not found a method to change the Language besides setting it manually in the requestpage before printing.

    I hope we find a solution here.

  • alvaro valbuena. Profile Picture
    alvaro valbuena. 30 on at
    RE: Why I can't assing a value to CurrReport.LANGUAGE?

    good evening. the same thing happens to me in a new Report, copy of 1302. Microsoft has not given an alternative to this?

  • Fernando Jose R Profile Picture
    Fernando Jose R 34 on at
    RE: Why I can't assing a value to CurrReport.LANGUAGE?

    I have seen other thing, if i run the report manually and usign the report as a variable I can change the Language

    pageextension 50120 "Posted Sales Invoice Ext" extends "Posted Sales Invoice"
    {

        actions
        {
            addlast(processing)
            {
                action(testreport)
                {
                    ApplicationArea = All;
                    trigger OnAction()
                    var
                        sain: Record "Sales Invoice Header";
                        repo: Report "test report";
                        LanguageMgmt: Codeunit Language;
                    begin
                        sain := Rec;
                        sain.SetRecFilter();
                        repo.Language := LanguageMgmt.GetLanguageIdOrDefault(Rec."Language Code");
                        repo.SetTableView(sain);
                        repo.Run();
                    end;

                }
            }
        }
    }
    but if I want change inside the repo using CurrReport this not works.
    pageextension 50120 "Posted Sales Invoice Ext" extends "Posted Sales Invoice"
    {

        actions
        {
            addlast(processing)
            {
                action(testreport)
                {
                    ApplicationArea = All;
                    trigger OnAction()
                    var
                        sain: Record "Sales Invoice Header";
                    begin
                        sain := Rec;
                        sain.SetRecFilter();
                        Report.Run(Report::"test report", true, true, sain);
                    end;

                }
            }
        }
    }
    report 50104 "test report"
    {
        ApplicationArea = All;
        Caption = 'test report';
        DefaultLayout = RDLC;
        RDLCLayout = './test.rdl';
        UsageCategory = Administration;
        dataset
        {
            dataitem(SalesInvoiceHeader; "Sales Invoice Header")
            {
                RequestFilterFields = "No.";
                column(No; "No.")
                {
                }
                column(labelNo; labelNo)
                {
                }
                column(LanguageCode; "Language Code")
                {
                }
                column(labelLan; labelLan)
                {
                }

                trigger OnAfterGetRecord()
                begin

                    CurrReport.Language := LanguageMgmt.GetLanguageIdOrDefault("Language Code");
                    Message(Format(LanguageMgmt.GetLanguageIdOrDefault("Language Code")));
                    Message(format(CurrReport.Language));
                end;

            }
        }

        requestpage
        {
            layout
            {
                area(content)
                {
                    group(GroupName)
                    {
                    }
                }
            }
            actions
            {
                area(processing)
                {
                }
            }
        }

        var
            LanguageMgmt: Codeunit Language;
            labelNo: TextConst ENU = 'Number', ESM = 'Numero';
            labelLan: TextConst ENU = 'Language', ESM = 'Lenguaje';


    }
    NOTA: I use TextConst in the example but the same thing happens with the Labels
  • Fernando Jose R Profile Picture
    Fernando Jose R 34 on at
    RE: Why I can't assing a value to CurrReport.LANGUAGE?

    Hi, then you say that this new fuctionality not permit modify the language of the report dynamicaly?

    I read the post and test the FastTab of Request Page and the Report Limits and Settings page and this work but the CurrReport.LANGUAGE(LanguageCodeunit.GetLanguageId(CustomerInfo."Language Code")); not works.

    You think this is a bug?

  • YUN ZHU Profile Picture
    YUN ZHU 74,115 Super User 2024 Season 2 on at
    RE: Why I can't assing a value to CurrReport.LANGUAGE?

    Hi, it seems to be related to the new feature below, I think you can test it.

    https://yzhums.com/35838/

    Hope this helps.

    Thanks.

    ZHU

  • Fernando Jose R Profile Picture
    Fernando Jose R 34 on at
    RE: Why I can't assing a value to CurrReport.LANGUAGE?

    _

  • Fernando Jose R Profile Picture
    Fernando Jose R 34 on at
    RE: Why I can't assing a value to CurrReport.LANGUAGE?

    Hi,

    I tried what you said but the problem is that CurrReport.LANGUAGE don't storage the value that I assign it.

    for example I use

    CurrReport.LANGUAGE := LanguageCodeunit.GetLanguageId('ENU');

    Message(format(CurrReport.LANGUAGE));

    the Message show me 2058 that is for Spanish (Mexico) and is the language that I configure in the client of BC

  • Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Why I can't assing a value to CurrReport.LANGUAGE?

    Hi,

    You can run this table 

    2000000050 "Language Selection"
     
    and check what is the language id you want to use in report and try with below code.
    CurrReport.LANGUAGE := Language.GetLanguageID(languageid)
    Let me know if it works for you.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans