Skip to main content

Notifications

Announcements

No record found.

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

  • Andy Sather Profile Picture
    Andy Sather on at
    RE: Create Customer with AL Code

    Thank you for replying back to your post.

  • Verified answer
    Maxence Profile Picture
    Maxence 55 on at
    RE: Create Customer with AL Code

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

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

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 Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,234 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,994 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans