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

Announcements

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

I have the same question (0)
  • Verified answer
    Suresh Kulla Profile Picture
    50,255 Super User 2026 Season 1 on at

    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

  • Romryan Profile Picture
    on at

    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");

  • Suggested answer
    Suresh Kulla Profile Picture
    50,255 Super User 2026 Season 1 on at

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

  • Romryan Profile Picture
    on at

    Suresh,

    Here is the screenshot

    pastedimage1611855109922v1.png

  • Suggested answer
    Suresh Kulla Profile Picture
    50,255 Super User 2026 Season 1 on at

    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

    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

  • Romryan Profile Picture
    on at

    Any idea/Suggestion?

  • Verified answer
    Suresh Kulla Profile Picture
    50,255 Super User 2026 Season 1 on at

    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

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,117 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,092 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 1,026 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans