Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

Create all customers as employes

(0) ShareShare
ReportReport
Posted on by 130

Hi All,

         Can anyone explain me on this create all customers as employees can we do this in AL  and is there any reference for how to create all customers as employess  if anyone knows help me.

Thank you.

  • Suggested answer
    Amit Baru Profile Picture
    Amit Baru 3,025 on at
    RE: Create all customers as employes

    DataItem Customer

    Var

    CheckEmployee : record Employee

    InsertEmployee : record Employee

    OnAfterRecord

    Begin

    if  CheckEmployee.get(Customer."No.") then begin

       CheckEmployee.First Name := Customer.Name;

       CheckEmployee.Modify;

    end else begin

    InsertEmployee.Init;

       InsertEmployee.."No." := Customer."No.";

       InsertEmployee.Insert;

       InsertEmployee.First Name := Customer.Name;

      InsertEmployee.Modify;

    end;

    end;

    Regards

    Amit Sharma

    www.erpconsultors.com

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Create all customers as employes

    Good to know

  • P V Sarath Profile Picture
    P V Sarath 130 on at
    RE: Create all customers as employes

    Hi Nithin,

                  Thank You Nithin it worked for me.

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Create all customers as employes

    Thanks.

    Please do as per below now I have removed customer variable

    report 50101 Process

    {

      UsageCategory = ReportsAndAnalysis;

      ApplicationArea = All;

      ProcessingOnly = true;

      dataset

      {

          dataitem(Customer; Customer)

          {

              RequestFilterFields = "No.", Name;

              column(Name; Name)

              {

              }

              trigger OnAfterGetRecord()

              var

                  Employee: Record Employee;

              begin

                      IF Not Employee.GET(Customer."No.") THEN BEGIN

                     Employee.INIT();

                     Employee."No." := customer."No.";

                     Employee.INSERT();

                 Employee."First Name" := Customer.Name;

                 Employee.Address := Customer.Address;

                 Employee."Address 2" := customer."Address 2";

                 Employee.City := customer.City;

                 Employee."E-Mail" := customer."E-Mail";

                 Employee.Modify();

              end;

              end;

          }

      }

      requestpage

      {

          layout

          {

              area(Content)

              {

                  group(GroupName)

                  {

                      // field(Name; SourceExpression)

                      // {

                      //     ApplicationArea = All;

                      // }

                  }

              }

          }

          actions

          {

              area(processing)

              {

                  action(ActionName)

                  {

                      ApplicationArea = All;

                  }

              }

          }

      }

    }

  • P V Sarath Profile Picture
    P V Sarath 130 on at
    RE: Create all customers as employes

    Hi Nitin,

                I am sharing my whole code

               report 50101 Process

    {

       UsageCategory = ReportsAndAnalysis;

       ApplicationArea = All;

       ProcessingOnly = true;

       dataset

       {

           dataitem(Customer; Customer)

           {

               RequestFilterFields = "No.", Name;

               column(Name; Name)

               {

               }

               trigger OnAfterGetRecord()

               var

                   Customer: Record Customer;

                   Employee: Record Employee;

               begin

                       IF Not Employee.GET(Customer."No.") THEN BEGIN

                      Employee.INIT();

                      Employee."No." := customer."No.";

                      Employee.INSERT();

                  Employee."First Name" := Customer.Name;

                  Employee.Address := Customer.Address;

                  Employee."Address 2" := customer."Address 2";

                  Employee.City := customer.City;

                  Employee."E-Mail" := customer."E-Mail";

                  Employee.Modify();

               end;

               end;

           }

       }

       requestpage

       {

           layout

           {

               area(Content)

               {

                   group(GroupName)

                   {

                       // field(Name; SourceExpression)

                       // {

                       //     ApplicationArea = All;

                       // }

                   }

               }

           }

           actions

           {

               area(processing)

               {

                   action(ActionName)

                   {

                       ApplicationArea = All;

                   }

               }

           }

       }

    }

    Can you check it.

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Create all customers as employes

    Share complete report code

  • P V Sarath Profile Picture
    P V Sarath 130 on at
    RE: Create all customers as employes

    Hi Nitin

              In the proccessinonly Report I am doing this.

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,091 Super User 2024 Season 1 on at
    RE: Create all customers as employes

    Also show your report filters if any

  • P V Sarath Profile Picture
    P V Sarath 130 on at
    RE: Create all customers as employes

    Hi All,

               I have wrote the code in the report for creating all customers as employess but my code is not working can anyone will help me. I am attaching the code of look at it and guide me guys

    trigger OnAfterGetRecord()

               var

                   Customer: Record Customer;

                   Employee: Record Employee;

               begin

                   IF Not Employee.GET(Customer."No.") THEN BEGIN

                       Employee.INIT();

                       Employee."No." := customer."No.";

                       Employee.INSERT();

                   END;

                   Employee."First Name" := Customer.Name;

                   Employee.Address := Customer.Address;

                   Employee."Address 2" := customer."Address 2";

                   Employee.City := customer.City;

                   Employee."E-Mail" := customer."E-Mail";

                   Employee.Modify();

               end;

    Thanks & Regards

    P V Sarath.

  • P V Sarath Profile Picture
    P V Sarath 130 on at
    RE: Create all customers as employes

    Hi All,

               I have wrote the code in the report for creating all customers as employess but my code is not working can anyone will help me. I am attaching the code of look at it and guide me guys

    trigger OnAfterGetRecord()

               var

                   Customer: Record Customer;

                   Employee: Record Employee;

               begin

                   IF Not Employee.GET(Customer."No.") THEN BEGIN

                       Employee.INIT();

                       Employee."No." := customer."No.";

                       Employee.INSERT();

                   END;

                   Employee."First Name" := Customer.Name;

                   Employee.Address := Customer.Address;

                   Employee."Address 2" := customer."Address 2";

                   Employee.City := customer.City;

                   Employee."E-Mail" := customer."E-Mail";

                   Employee.Modify();

               end;

    Thanks & Regards

    P V Sarath.

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

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans