Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

BC AL Code issues

Posted on by 151

Dear all,

from the general ledger entries, we have the option for print the voucher for all the transactions. Right now we want to bring approvers name on the prints. (1st level, 2nd level etc) which comes from the Posted approval entries.

Approver 1 and approver 2 for this eg

appr.jpg

gl.jpg

what all the corrections need to do in this coding ..pls request all your helps

reportextension 58101 "ApproverId-GL Register" extends "GL Register Report One"
{
    dataset
    {
        // Add changes to dataitems and columns here
        add("G/L Entry")
        {

        }
        add(PageLoop)
        {
            column(Approver1; Approver1)
            {
            }
        }
        modify("G/L Entry")
        {
            trigger OnAfterAfterGetRecord()
            var
                ApprovalEntry: Record "Posted Approval Entry";
            begin
                Clear(Approver1);
                ApprovalEntry.Reset();
                ApprovalEntry.SetRange("Document No.", "G/L Entry"."No.");
                IF ApprovalEntry.FindFirst() then
                    Approver1 := ApprovalEntry."Approver ID"
            end;
        }


    }

    rendering
    {
        layout(LayoutName)
        {
            Type = RDLC;
            LayoutFile = './ReportLayouts/GLRegisterNewOnee.rdl';
        }
    }
    var
        Approver1: Code[20];
        Approver2: Code[20];
}

  • aryaps Profile Picture
    aryaps 151 on at
    RE: BC AL Code issues

    Thannks for the repsonse. its compiled sucessfully. but am facing an issue in rdl

    while opening the rdl file, there is no dataset is showing. dont know what happend suddenly.

    On Down Connect now is showing. i reisntalled microsft report builder also but none of the reports while opening dataset is not loading

    what may be the issue?

  • Suggested answer
    NAV_with_Narang Profile Picture
    NAV_with_Narang 2,234 Super User 2024 Season 1 on at
    RE: BC AL Code issues

    Follow through the below steps. There's an easy way and a time consuming one too, see what works:

    EASY (requires no logic, not recommended - use for triage purpose only):

    In your current report extension, on OnAfterGetRecord of GL Entries dataitem. Or you can copy the default report into a new one and perform this there

    1. If you know that the Number of approvers (Approval Sequence) is going to be less than 4, create 4 different variables

    2. Now follow the below code and paste it

    trigger OnAfterAfterGetRecord()
    var
    ApprovalEntry: Record "Posted Approval Entry";
    begin
    Clear(Approver1);
    Clear(Approver2);
    Clear(Approver3);
    Clear(Approver4);
    ApprovalEntry.Reset();
    ApprovalEntry.SetRange("Document No.", "G/L Entry"."No.");
    IF ApprovalEntry.FindSet() then
    repeat
    If ApprovalEntry."Sequence No." = 1 then
    Approver1 := ApprovalEntry."Approver ID"
    else
    if ApprovalEntry."Sequence No." = 2 then
    Approver2 := ApprovalEntry."Approver ID"
    else
    if ApprovalEntry."Sequence No." = 3 then
    Approver3 := ApprovalEntry."Approver ID"
    else
    if ApprovalEntry."Sequence No." = 4 then
    Approver4 := ApprovalEntry."Approver ID"
    Until ApprovalEntry.Next() = 0;
    end;

    Print these 4 variables in 4 different text boxes in the report. The variables which do not have value will print blank

    Challenging (requires logic & some understanding of report functioning in BC, recommended):

    1. I'd recommend copy the default report and create a new one on a 50000 ID. If you do not know how to do that, do write back

    2. In the copied report, add "Posted Approval Entries" as the child dataitem under G/L Entry & see if you can establish a DataItemLinkReference between GL Entry & Posted Approval Entries.

    3. You do not need to write any code after DataItemLinkReference is specified. Read about it in MSDN blogs

    4. Now declare columns for your Posted Approval Entries. In the report layout you may need to add a Sequence No subgroup to the GL Entry's original group

    5. Run and see the report

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: BC AL Code issues

    Can you please try as per below?

    reportextension 58101 "ApproverId-GL Register" extends "G/L Register"
    {
        dataset
        {
            // Add changes to dataitems and columns here
            add("G/L Entry")
            {
                column(Approver1; Approver1)
                { }
                column(Approver2; Approver2)
                { }

            }
            modify("G/L Entry")
            {
                trigger OnAfterAfterGetRecord()
                var
                    ApprovalEntry: Record "Posted Approval Entry";
                begin
                    Clear(Approver1);
                    ApprovalEntry.Reset();
                    ApprovalEntry.SetRange("Document No.", "G/L Entry"."Document No.");
                    IF ApprovalEntry.FindFirst() then
                        Approver1 := ApprovalEntry."Approver ID"
                end;
            }


        }

        rendering
        {
            layout(LayoutName)
            {
                Type = RDLC;
                LayoutFile = './ReportLayouts/GLRegisterNewOnee.rdl';
            }
        }
        var
            Approver1: Code[20];
            Approver2: Code[20];
    }
  • aryaps Profile Picture
    aryaps 151 on at
    RE: BC AL Code issues

    Anyone pls help me on this?

  • aryaps Profile Picture
    aryaps 151 on at
    RE: BC AL Code issues

    am trying to extend the report. i don't have much exp in bc,its my starting stage.

    Requirement is if there is one level or 2 level or 3 level approval is there in particular transaction it should display in the prints

    error AL0682: A DataItem or Column with name '"G/L Entry"' could not be found in the target GL Register Report One.

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: BC AL Code issues

    what is the problem you are facing?

    Thanks

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,030 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans