Convergence 2006: Microsoft Dynamics NAV - Meet the Experts

AdministratorAdministrator Member, Moderator, Administrator Posts: 2,500
edited 2006-08-26 in Download section
Convergence 2006: Microsoft Dynamics NAV - Meet the Experts
Still need answers? This is an opportunity to ask the experts your specific questions not covered in the previous sessions about the Microsoft Dynamics NAV 4.0 application and features, as well as the future strategy and road map of Microsoft Dynamics NAV.

Speaker: Niels Nybo Jensen

Duration: 1:26:07

http://www.mibuso.com/dlinfo.asp?FileID=605

Discuss this download here.

Comments

  • ara3nara3n Member Posts: 9,256
    Hello While listening to the presentation. One user asked on how to merge dublicate customers. Basically a user doesn't find a customer and creates a new customer and then posts the transaction. The following report/code will merge two vendors
    OBJECT Report 50043 Combine Vendors
    {
      OBJECT-PROPERTIES
      {
        Date=05/29/06;
        Time=[ 2:07:55 PM];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        ProcessingOnly=Yes;
        OnPreReport=BEGIN
                      IF NOT CONFIRM(STRSUBSTNO(TecText,VendorNo1,VendorNo2)) THEN
                         ERROR('');
    
                      Vendor.GET(VendorNo2);
                      Vendor.DELETE;
    
    
                      CommentLine.SETRANGE("Table Name",CommentLine."Table Name"::Vendor);
                      CommentLine.SETRANGE("No.",VendorNo1);
                      IF CommentLine.FIND('-') THEN REPEAT
                         CommentLine2.SETRANGE("Table Name",CommentLine."Table Name"::Vendor);
                         CommentLine2.SETRANGE("No.",VendorNo2);
                         IF CommentLine2.FIND('+') THEN;
                         CommentLine3 := CommentLine;
                         CommentLine3."No." := VendorNo2;
                         CommentLine3."Line No." := CommentLine2."Line No." + 10000;
                         CommentLine3.INSERT;
                         CommentLine.DELETE;
                      UNTIL CommentLine.NEXT = 0;
    
                      CommentLine2.SETRANGE("Table Name",CommentLine."Table Name"::Vendor);
                      CommentLine2.SETRANGE("No.",VendorNo2);
                      IF CommentLine2.FIND('+') THEN;
                      CommentLine3.INIT;
                      CommentLine3.Code := 'MERGE';
                      CommentLine3."Table Name" := CommentLine3."Table Name"::Vendor;
                      CommentLine3."No." := VendorNo2;
                      CommentLine3.Date := TODAY;
    
                      CommentLine3.Comment := 'Vendor ' +VendorNo1+ ' was merged';
                      CommentLine3."Line No." := CommentLine2."Line No." + 10000;
                      CommentLine3.INSERT;
    
                      DefaultDim1.SETRANGE("Table ID",DATABASE::Vendor);
                      DefaultDim1.SETRANGE("No.",VendorNo1);
                      DefaultDim1.DELETEALL;
    
                      Vendor.GET(VendorNo1);
                      Vendor2 := Vendor;
                      Vendor.RENAME(VendorNo2);
    
    
                      Vendor2.INSERT;
                      Vendor2.DELETE(TRUE);
                    END;
    
      }
      DATAITEMS
      {
      }
      REQUESTFORM
      {
        PROPERTIES
        {
          Width=8910;
          Height=3960;
        }
        CONTROLS
        {
          { 1000000000;TextBox;3960 ;550  ;4620 ;440  ;SourceExpr=VendorNo1;
                                                       TableRelation=Vendor }
          { 1000000001;Label  ;550  ;550  ;2860 ;440  ;ParentControl=1000000000;
                                                       CaptionML=ENU=Delete Vendor }
          { 1000000002;TextBox;3960 ;1210 ;4620 ;440  ;SourceExpr=VendorNo2;
                                                       TableRelation=Vendor }
          { 1000000003;Label  ;550  ;1210 ;2970 ;440  ;ParentControl=1000000002;
                                                       CaptionML=ENU=Merge into Vendor }
        }
      }
      CODE
      {
        VAR
          VendorNo1@1000000000 : Code[20];
          VendorNo2@1000000001 : Code[20];
          Vendor@1000000002 : Record 23;
          TecText@1000000004 : TextConst 'ENU=Are you sure you want Merge Customer %1 into Customer %2';
          Vendor2@1000000007 : Record 23;
          CommentLine@1000000003 : Record 97;
          CommentLine2@1000000005 : Record 97;
          CommentLine3@1000000006 : Record 97;
          DefaultDim1@1000000008 : Record 352;
    
        BEGIN
        END.
      }
    }
    
    
    

    The following will merge two customers.
    OBJECT Report 50044 Combine Customers
    {
      OBJECT-PROPERTIES
      {
        Date=05/10/06;
        Time=[ 4:05:48 PM];
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        ProcessingOnly=Yes;
        OnPreReport=BEGIN
                      IF NOT CONFIRM(STRSUBSTNO(TecText,CustomerNo1,CustomerNo2)) THEN
                         ERROR('');
    
                      Customer.GET(CustomerNo2);
                      Customer.DELETE;
    
    
                      CommentLine.SETRANGE("Table Name",CommentLine."Table Name"::Customer);
                      CommentLine.SETRANGE("No.",CustomerNo1);
                      IF CommentLine.FIND('-') THEN REPEAT
                         CommentLine2.SETRANGE("Table Name",CommentLine."Table Name"::Customer);
                         CommentLine2.SETRANGE("No.",CustomerNo2);
                         IF CommentLine2.FIND('+') THEN;
                         CommentLine3 := CommentLine;
                         CommentLine3."No." := CustomerNo2;
                         CommentLine3."Line No." := CommentLine2."Line No." + 10000;
                         CommentLine3.INSERT;
                         CommentLine.DELETE;
                      UNTIL CommentLine.NEXT = 0;
    
                      CommentLine2.SETRANGE("Table Name",CommentLine."Table Name"::Customer);
                      CommentLine2.SETRANGE("No.",CustomerNo2);
                      IF CommentLine2.FIND('+') THEN;
                      CommentLine3.INIT;
                      CommentLine3.Code := 'MERGE';
                      CommentLine3."Table Name" := CommentLine3."Table Name"::Customer;
                      CommentLine3."No." := CustomerNo2;
                      CommentLine3.Date := TODAY;
    
                      CommentLine3.Comment := 'Customer ' +CustomerNo1+ ' was merged';
                      CommentLine3."Line No." := CommentLine2."Line No." + 10000;
                      CommentLine3.INSERT;
    
                      DefaultDim1.SETRANGE("Table ID",DATABASE::Customer);
                      DefaultDim1.SETRANGE("No.",CustomerNo1);
                      DefaultDim1.DELETEALL;
    
                      Customer.GET(CustomerNo1);
                      Customer2 := Customer;
                      Customer.RENAME(CustomerNo2);
    
    
                      Customer2.INSERT;
                      Customer2.DELETE(TRUE);
                    END;
    
      }
      DATAITEMS
      {
      }
      REQUESTFORM
      {
        PROPERTIES
        {
          Width=8910;
          Height=3960;
        }
        CONTROLS
        {
          { 1000000000;TextBox;3960 ;550  ;4620 ;440  ;SourceExpr=CustomerNo1;
                                                       TableRelation=Customer }
          { 1000000001;Label  ;550  ;550  ;2860 ;440  ;ParentControl=1000000000;
                                                       CaptionML=ENU=Delete Customer }
          { 1000000002;TextBox;3960 ;1210 ;4620 ;440  ;SourceExpr=CustomerNo2;
                                                       TableRelation=Customer }
          { 1000000003;Label  ;550  ;1210 ;2970 ;440  ;ParentControl=1000000002;
                                                       CaptionML=ENU=Merge into Customer }
        }
      }
      CODE
      {
        VAR
          CustomerNo1@1000000000 : Code[20];
          CustomerNo2@1000000001 : Code[20];
          Customer@1000000002 : Record 18;
          TecText@1000000004 : TextConst 'ENU=Are you sure you want Merge Customer %1 into Customer %2';
          Customer2@1000000007 : Record 18;
          CommentLine@1000000003 : Record 97;
          CommentLine2@1000000005 : Record 97;
          CommentLine3@1000000006 : Record 97;
          DefaultDim1@1000000008 : Record 352;
    
        BEGIN
        END.
      }
    }
    
    
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • ara3nara3n Member Posts: 9,256
    The following rule can be applies to Items, GL Accounts, Basically any master tables.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.