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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Create Customer with AL Code

(0) ShareShare
ReportReport
Posted on by 55

Hi, 
I am trying to create a client via code in a Sandbox environment.
Here is the code I am using :

CustomerRec.Init;
        SalesReceivablesSetup.GET();

        CustomerRec."No." := NoSeriesMgt.GetNextNo(SalesReceivablesSetup."Customer Nos.", WorkDate(), true);

        CustomerRec.Name := 'XXX';
        CustomerRec."Gen. Bus. Posting Group" := format('BINNENLAND');

        if CustomerRec.Insert() then begin
            exit(true)
        end else begin
            Message('Une erreur est survenue lors de la création du client!');
            exit(false);
        end;


When inserting, I get the following error: "Gen. Bus.  Posting Group" empty

pastedimage1667577731899v1.png

pastedimage1667577842202v2.png

Do you have any idea where the error could come from?

Thanks

I have the same question (0)
  • Verified answer
    Maxence Profile Picture
    55 on at

    Sorry, I noticed that my object was not the right one.

    If I pass the right object, the insert is done correctly

  • Andy Sather Profile Picture
    Microsoft Employee on at

    Thank you for replying back to your post.

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 1,857 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,047 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 959 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans