Rename Primary Key
Sankaran_Balasubramonian
Member Posts: 20
Hi All,
I am trying to rename a primary key field of a table, and am running into problems. Please advice.
Scenario
I am currently working on the Default Navision Job Master table. (Jobs : 167). The client requires to auto generate the number series for the Job based on certain conditions. The conditions are
a. Job Type (Could Be Any Thing)
b. Job Level (Boolean corresponds to Parent - Child).
Please refer the Fig00101 below for more information on the field placings.
I have also created a separate table, where the Job Type - Job Level - Number Series combination would be captured. Please refer Fig00102.
Now based on the user input in these two fields, I would want to create a new number for the Job. Since Navision creates the number when the user presses F3, I would have to replace that number and show custom generated number in the field. I have written the following code to achieve that.
Problem
Everything works fine. But when I try to close the window, I get a warning message saying "Rename Record ?". Please refer Fig00103.
Throughout my code, I have not used the RENAME keyword. And I looked into MIBUSO forums from where I figured out that it is better to DELETE + INSERT than to RENAME.
http://www.mibuso.com/forum/viewtopic.php?f=14&t=16743&hilit=Rename+REcord
Please do let me know how to overcome this problem. Thanks in advance for all the help.
I am trying to rename a primary key field of a table, and am running into problems. Please advice.
Scenario
I am currently working on the Default Navision Job Master table. (Jobs : 167). The client requires to auto generate the number series for the Job based on certain conditions. The conditions are
a. Job Type (Could Be Any Thing)
b. Job Level (Boolean corresponds to Parent - Child).
Please refer the Fig00101 below for more information on the field placings.
I have also created a separate table, where the Job Type - Job Level - Number Series combination would be captured. Please refer Fig00102.
Now based on the user input in these two fields, I would want to create a new number for the Job. Since Navision creates the number when the user presses F3, I would have to replace that number and show custom generated number in the field. I have written the following code to achieve that.
// Get - Set The Number Based On Job Type
IF "Job Type" = '' THEN
BEGIN
ERROR('Please select a Job Type to proceed.');
EXIT;
END
ELSE
BEGIN
IF NVJobMstr.GET("Job Type") = TRUE THEN
BEGIN
// Check Which No. Series To Get
IF "Is Child" = TRUE THEN
BEGIN
// Get The Next Number Using Child Number Series
sDocNo := NoSeriesMgt.GetNextNo(NVJobMstr."Child No. Series",0D,TRUE);
END
ELSE
BEGIN
// Get The Next Number Using Child Number Series
sDocNo := NoSeriesMgt.GetNextNo(NVJobMstr."Parent No. Series",0D,TRUE);
END;
END
ELSE
BEGIN
ERROR('A Get operation on table NV Job Type Master failed accessing data.');
EXIT;
END;
END;
// Delete Old Record From Table
IF DELETE(TRUE) = FALSE THEN
BEGIN
ERROR('A Delete operation on table Jobs failed accessing data.');
END;
// Insert New Data Into Table
"No." := sDocNo;
IF INSERT(TRUE) = FALSE THEN
BEGIN
ERROR('An Insert operation on table Jobs failed accessing data.');
END;
// Reset The Current Record
RESET;
Problem
Everything works fine. But when I try to close the window, I get a warning message saying "Rename Record ?". Please refer Fig00103.
Throughout my code, I have not used the RENAME keyword. And I looked into MIBUSO forums from where I figured out that it is better to DELETE + INSERT than to RENAME.
http://www.mibuso.com/forum/viewtopic.php?f=14&t=16743&hilit=Rename+REcord
Please do let me know how to overcome this problem. Thanks in advance for all the help.
--
Thanks & Best Regards
Sankaran Balasubramonian
Thanks & Best Regards
Sankaran Balasubramonian
0
Comments
-
I've gotten this before when I call the UPDATE function. Changing it to UPDATE(FALSE) fixes the issue.0
-
In this case I will preffer way around like using "internal" numbers for real Job No. and the number series selected on some conditions you can store into new field or into search name field etc. Because the way how you are doing it will lead to this kind of problems. Or you can use some sort of "wizard" to crete the record, which will collect the info from the user first, and than it will create the record with correct no. series...(may be best way when I am thinking about it) ;-)0
-
redesign the logic so that you use standard nav job series numbers and just have the other two fields as properties of the job. There is no need to do it the way you are going.
take two steps back and start again.David Singleton0 -
kine wrote:In this case I will preffer way around like using "internal" numbers for real Job No. and the number series selected on some conditions you can store into new field or into search name field etc.
as usual, Kine was quicker.David Singleton0 -
David Singleton wrote:redesign the logic so that you use standard nav job series numbers and just have the other two fields as properties of the job. There is no need to do it the way you are going.
take two steps back and start again.
Hi David,
Can you please explain more in detail. I am pretty new to NAV. I have been working in Dynamics GP for more than 5yrs, now slowly shifting over to NAV. It would be of great help if you can explain as to how I can create properties for job. Are we trying to create a new form or something like that, and then link that to the main job form. Please do explain.--
Thanks & Best Regards
Sankaran Balasubramonian0 -
David Singleton wrote:kine wrote:In this case I will preffer way around like using "internal" numbers for real Job No. and the number series selected on some conditions you can store into new field or into search name field etc.
as usual, Kine was quicker.
Hi Kine,
The client has a lot of customizations done on the Job Module. So if I store if else where, I will have to extended this number across all those customizations. Please advice.--
Thanks & Best Regards
Sankaran Balasubramonian0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 250 Dynamics CRM
- 102 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions


