Skip to main content
Business Central forum
Answered

Create Customer with AL Code

editSubscribe (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

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

What Motivates a Super User?

We know many of you visit the Dynamics 365 Community and Power Platform…

Demystifying Copilot with Georg Glantschnig…

Industry experts answer burning questions directly from our amazing Community…

Setting Up Knowledge Sources for Copilot…

Look at how configuring a comprehensive knowledge base is crucial…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,068 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,591 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Product updates

Dynamics 365 release plans