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

Notifications

Announcements

No record found.

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,243 Super User 2025 Season 2 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,243 Super User 2025 Season 2 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,243 Super User 2025 Season 2 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,243 Super User 2025 Season 2 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,785

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,007 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 948 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans