Skip to main content

Notifications

Community site session details

Community site session details

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

G/L code doesn't exist BC/ AL error

(0) ShareShare
ReportReport
Posted on by

Dear All,

When doing a General or Purchase journal, I have an extension whereby when I select "Account No." field, the GL account attached to respective posting group i.e. vendor posting group needs to be retrieved and its balance read. My issue is when I select the Account Type i.e. vendor, I get an error below before I select the vendor account. But if the Vendor account type is default in my journal line, I don't get error ,I am allowed to select the vendor account and my code works as expected. I need the liberty to select the account type of my choice i.e. vendor, employee etc with no error so I can the vendor of my choice or employee without this error. I don't understand why this error is coming if I haven't selected the vendor or employee himself.

pastedimage1611772884124v1.png

Code extract

begin

                   

                    If "Account Type" = "Account Type"::Vendor then

                   

                    begin

                       

                       If Vend.Get(Rec."Account No.") then

                       If VendAccPostGrp.Get(Vend."Vendor Posting Group") then

                        Message(VendAccPostGrp."Payables Account");                      

                    

                    

                      GLAcc.Get(VendAccPostGrp."Payables Account");

                      

                      GLAcc.SETRANGE("Date Filter",0D,TODAY);  

                      GLAcc.CalcFields(Balance);

                      End

end

  • Verified answer
    Suresh Kulla Profile Picture
    47,789 on at
    RE: G/L code doesn't exist BC/ AL error

    Looks like the Posting Group does not have Cost Account setup, try the below code

    If "Account Type" = "Account Type"::"Fixed Asset" then                  

                      Begin                                    

                        If FA.Get(Rec."Account No.") then

                        Begin

                        If FaAccPostGrp.Get(FA."FA Posting Group") then

                           Message(FaAccPostGrp."Acquisition Cost Account");

        IF FaAccPostGrp."Acquisition Cost Account" <> '' then begin                

                        GLAcc.Get(FaAccPostGrp."Acquisition Cost Account");

                        GLAcc.SETRANGE("Date Filter",0D,TODAY);  

                        GLAcc.CalcFields(Balance);      

        end;                                

                        End

                      End

  • Romryan Profile Picture
    on at
    RE: G/L code doesn't exist BC/ AL error

    Any idea/Suggestion?

  • Romryan Profile Picture
    on at
    RE: G/L code doesn't exist BC/ AL error

    Here is the codes

    If "Account Type" = "Account Type"::"Fixed Asset" then                    

                       Begin                                    

                         If FA.Get(Rec."Account No.") then

                         Begin

                         If FaAccPostGrp.Get(FA."FA Posting Group") then

                            Message(FaAccPostGrp."Acquisition Cost Account");                    

                         GLAcc.Get(FaAccPostGrp."Acquisition Cost Account");

                         GLAcc.SETRANGE("Date Filter",0D,TODAY);  

                         GLAcc.CalcFields(Balance);                                        

                         End

                       End

  • Suggested answer
    Suresh Kulla Profile Picture
    47,789 on at
    RE: G/L code doesn't exist BC/ AL error

    Please send  me your code, looks like you are executing your code irrespective of Account Type, You need to check Account type and have that a main IF condition with begin end.

  • Romryan Profile Picture
    on at
    RE: G/L code doesn't exist BC/ AL error

    Suresh,

    Here is the screenshot

    pastedimage1611855109922v1.png

  • Suggested answer
    Suresh Kulla Profile Picture
    47,789 on at
    RE: G/L code doesn't exist BC/ AL error

    Are you still getting error? send us the screenshot of it.

  • Romryan Profile Picture
    on at
    RE: G/L code doesn't exist BC/ AL error

    Thank you very much.This worked on other Account types except Fixed assets I don't know why.

    If FA.Get(Rec."Account No.") then

                         Begin

                         If FaAccPostGrp.Get(FA."FA Posting Group") then

                            Message(FaAccPostGrp."Acquisition Cost Account");

  • Verified answer
    Suresh Kulla Profile Picture
    47,789 on at
    RE: G/L code doesn't exist BC/ AL error

    Your  if statement should be in begin end , you execute all the below code only when you get the vendor record

     If Vend.Get(Rec."Account No.") then begin 

    end

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

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

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 1,169

#2
YUN ZHU Profile Picture

YUN ZHU 1,006 Super User 2025 Season 1

#3
Mansi Soni Profile Picture

Mansi Soni 830

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans