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

BC AL Code issues

(0) ShareShare
ReportReport
Posted on by 155

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];
}

I have the same question (0)
  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    what is the problem you are facing?

    Thanks

  • aryaps Profile Picture
    155 on at

    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.

  • aryaps Profile Picture
    155 on at

    Anyone pls help me on this?

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    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];
    }
  • Suggested answer
    NAV_with_Narang Profile Picture
    2,384 Moderator on at

    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

  • aryaps Profile Picture
    155 on at

    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?

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