mibuso.com

Microsoft Business Solutions online community
It is currently Sat May 25, 2013 12:03 pm

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: How to Merge customers Vendors, GL Accounts
PostPosted: Wed Dec 20, 2006 6:40 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 8703
Location: 3rd rock from sun
Country: United States (us)
Hello Here is an example on how to merge customers. This can be used and changed to merge vendors, GL accounts.
The basic logic is this.

CustA.get(A);

CustA.Delete;

CustB.get(B);

CustB.rename(A);

Code: Select all
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.
  }
}




_________________
Rashed.

blog: http://mibuso.com/blogs/ara3n/


Last edited by ara3n on Sun Jan 24, 2010 1:50 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 21, 2007 5:16 am 
Offline

Joined: Thu Aug 17, 2006 4:10 pm
Posts: 225
Location: NY
Country: United States (us)
What Would happen in table18
Code: Select all
OnDelete()
MoveEntries.MoveCustEntries(Rec);


Do we need to put new Customer.No. into Customer No. field in Cust. Ledger Entry table?

This is such a cool idea and it might help me with s lot of small things at work! \:D/

Best,
CouberPu


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 21, 2007 6:56 am 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 8703
Location: 3rd rock from sun
Country: United States (us)
My routine does not run that ondelete trigger. So the code is not run.

Quote:
Do we need to put new Customer.No. into Customer No. field in Cust. Ledger Entry table?

No you don't. Navision will automatically do it for you.


Yep it's a great idea, :)

_________________
Rashed.

blog: http://mibuso.com/blogs/ara3n/


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 25, 2007 8:40 pm 
Offline

Joined: Mon Feb 14, 2005 12:58 pm
Posts: 26
Location: Copenhagen
Country: Denmark (dk)
well, what about customer ledger entries etc.???

_________________
Best regards
Henrik Ohm


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 25, 2007 11:15 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Fri Jun 11, 2004 9:05 pm
Posts: 4858
Location: Los Angeles, CA
Country: United States (us)
henrikohm wrote:
well, what about customer ledger entries etc.???


It will be automatically changed when Navision does the rename.

_________________
Confessions of a Dynamics NAV Consultant = my blog
AP Commerce, Inc. = where I work


Top
 Profile E-mail WWW  
 
 Post subject: thanks
PostPosted: Mon Feb 18, 2008 11:49 am 
Offline

Joined: Wed Feb 13, 2008 10:54 am
Posts: 12
Location: Ukraine
Country: Ukraine (ua)
Thanks ara3n
:)

_________________
Navision Training Courses


Top
 Profile  
 
 Post subject: Re: thanks
PostPosted: Mon Feb 18, 2008 7:41 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 8703
Location: 3rd rock from sun
Country: United States (us)
navex wrote:
Thanks ara3n
:)


It's nice to see random "thank you" in your old posts. :)

_________________
Rashed.

blog: http://mibuso.com/blogs/ara3n/


Top
 Profile  
 
 Post subject: Re: How to Merge customers Vendors, GL Accounts
PostPosted: Mon Mar 16, 2009 12:25 pm 
Offline

Joined: Thu Oct 30, 2008 10:38 am
Posts: 987
Location: Earth
Country: Netherlands (nl)
Thank you ara3n

_________________
|Pressing F1 is so much faster than opening your browser|
|MCBMSS: 5.0 intro|MCTS:NAV09 839..841|JetReports© Certified Specialist|
|Dynamics Anywhere: Mobile Business Solutions|


Top
 Profile  
 
 Post subject: Re: How to Merge customers Vendors, GL Accounts
PostPosted: Mon Mar 16, 2009 1:39 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 8703
Location: 3rd rock from sun
Country: United States (us)
you are welcome.

_________________
Rashed.

blog: http://mibuso.com/blogs/ara3n/


Top
 Profile  
 
 Post subject: Re: How to Merge customers Vendors, GL Accounts
PostPosted: Wed Apr 22, 2009 10:40 pm 
Offline

Joined: Fri Aug 29, 2008 1:47 am
Posts: 260
Location: Louisville
Country: United States (us)
Haven't tried it yet, but I'm going to be doing testing later. Consider this a preemptive thank you, I'll only come back if I have trouble with something :D

_________________
"OMG ALL MY DATA IS GONE"
"Show All..."
"Oh..."


Top
 Profile  
 
 Post subject: Re: How to Merge customers Vendors, GL Accounts
PostPosted: Thu Apr 23, 2009 1:19 am 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 8703
Location: 3rd rock from sun
Country: United States (us)
Consider this a preemptive you are welcome. :)

_________________
Rashed.

blog: http://mibuso.com/blogs/ara3n/


Top
 Profile  
 
 Post subject: Re: How to Merge customers Vendors, GL Accounts
PostPosted: Mon May 10, 2010 9:57 am 
Offline
Site Supporter

Joined: Thu Feb 28, 2008 11:47 pm
Posts: 102
Location: Moscow
Country: Russia (ru)
Hi Rashed!

I have tried your code and it worked so great. Thank you very much. :D

BTW, before finding your post I unsuccessfully tried to merge customers using standard NAV functionality: Customer Card > Customer > Combine Customers. Got too many difficulties...

Best Regards


Top
 Profile  
 
 Post subject: Re: How to Merge customers Vendors, GL Accounts
PostPosted: Mon May 10, 2010 1:55 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 8703
Location: 3rd rock from sun
Country: United States (us)
you are welcome.

_________________
Rashed.

blog: http://mibuso.com/blogs/ara3n/


Top
 Profile  
 
 Post subject: Re: How to Merge customers Vendors, GL Accounts
PostPosted: Wed May 12, 2010 3:18 pm 
Offline

Joined: Mon Jan 23, 2006 3:04 pm
Posts: 37
Location: Slovenia
Country: Slovenia (si)
This is an example of thinking outside the box, nice.


Top
 Profile  
 
 Post subject: Re: How to Merge customers Vendors, GL Accounts
PostPosted: Wed May 12, 2010 5:26 pm 
Offline
MVP Microsoft Dynamics NAV

Joined: Wed Dec 15, 2004 6:11 pm
Posts: 8703
Location: 3rd rock from sun
Country: United States (us)
Thanks :)

_________________
Rashed.

blog: http://mibuso.com/blogs/ara3n/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum


Search for:
Jump to: