Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Suggested answer

Create all customers as employes

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.

Categories:
  • 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,023 Moderator 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,023 Moderator 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,023 Moderator 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,023 Moderator 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

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

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

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,537 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,520 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans