Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Answered

Create Customer with AL Code

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

Categories:
  • 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

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,768 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,985 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans