Renaming A Record In Code

Jonathan2708
Member Posts: 552
Hi,
In my app, customers are coded based on their customer type - FINance, RETail, COMmercial, so Customer No. is FIN, RET or COM plus an incrementing number. e.g. FIN-0030
When a user changes the customer type field in a record I need to change the primary key to reflect their new account no. Presently I have the following code in the Customer Type - OnValidate() event on the Customer table :
IF (Rec."Customer Type" <> xRec."Customer Type") THEN BEGIN
// Procedure For Changing Contract Type
// First Rename Account Record
SalesSetup.GET;
SalesSetup.TESTFIELD("Finance Customer Nos.");
NewAccountNo := NoSeriesMgt.GetNextNo(SalesSetup."Finance Customer Nos.", 0D, TRUE);
NewRecordVar.RESET;
NewRecordVar.GET(Rec."No.");
NavResult := NewRecordVar.RENAME(NewAccountNo);
END;
This renames the record ok, but I need the screen to refresh properly and automatically move to the newly recoded record.
Any help appreciated, including any alternative (better) methods of doing this.
Jonathan
In my app, customers are coded based on their customer type - FINance, RETail, COMmercial, so Customer No. is FIN, RET or COM plus an incrementing number. e.g. FIN-0030
When a user changes the customer type field in a record I need to change the primary key to reflect their new account no. Presently I have the following code in the Customer Type - OnValidate() event on the Customer table :
IF (Rec."Customer Type" <> xRec."Customer Type") THEN BEGIN
// Procedure For Changing Contract Type
// First Rename Account Record
SalesSetup.GET;
SalesSetup.TESTFIELD("Finance Customer Nos.");
NewAccountNo := NoSeriesMgt.GetNextNo(SalesSetup."Finance Customer Nos.", 0D, TRUE);
NewRecordVar.RESET;
NewRecordVar.GET(Rec."No.");
NavResult := NewRecordVar.RENAME(NewAccountNo);
END;
This renames the record ok, but I need the screen to refresh properly and automatically move to the newly recoded record.
Any help appreciated, including any alternative (better) methods of doing this.
Jonathan
0
Comments
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions