recEmployee.RESET; recEmployee.SETFILTER("No.",'?????'); // codes are always 5 characters IF recEmployee.FIND('-') THEN REPEAT recEmployee2 := recEmployee; recEmployee2."SSNo." := recEmployee2."No."; CASE COPYSTR(recEmployee."No.",1,1) OF 'A': codNewNo := '01'; 'B': codNewNo := '02'; 'C': codNewNo := '03'; 'D': codNewNo := '04'; 'E': codNewNo := '05'; 'F': codNewNo := '06'; 'G': codNewNo := '07'; 'H': codNewNo := '08'; 'I': codNewNo := '09'; 'J': codNewNo := '10'; 'K': codNewNo := '11'; 'L': codNewNo := '12'; 'M': codNewNo := '13'; 'N': codNewNo := '14'; 'O': codNewNo := '15'; 'P': codNewNo := '16'; 'Q': codNewNo := '17'; 'R': codNewNo := '18'; 'S': codNewNo := '19'; 'T': codNewNo := '20'; 'U': codNewNo := '21'; 'V': codNewNo := '22'; 'W': codNewNo := '23'; 'X': codNewNo := '24'; 'Y': codNewNo := '25'; 'Z': codNewNo := '26'; END; recEmployee2.RENAME(codNewNo + COPYSTR(recEmployee."No.",2)); COMMIT; // this commit can be useful in case the process is interupted. With this you can continue where it left of // the records already renamed will NOT be renamed again because of the SETFILTER("No.",...) UNTIL recEmployee.NEXT = 0;](*,)
Comments
example:
How does this look to you... ? 8-[
Appears to work for me.
Generating number from first character we solved in another post... ;-)
You can "speed up" the process by temporary removing all the Employee.No. table relations on fields you are not using. But you need to know what you are doing...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
http://www.BiloBeauty.com
http://www.autismspeaks.org
If you're going to remove all TableRelations in other related tables, You can loop through the related tables on their primary key.
If for example a employee is connected to a job (employee no. is present in the job-table) you have to delete the TableRelation on the employee no..
First rename the employee table.
Then loop through the job-table and look in the just renamed employee table if there is a record which contains the old employee no..
If you find that record, use the new employee no. in the job-table and modify the job-table.
Like Kamil said; You need to know what you're doing.
Good luck!
Tino Ruijs
Microsoft Dynamics NAV specialist
kine i am using Native database on 4.0
Any other fast suggestion?
Thanks
You could take a look how many fields have a tablerelation to the employee table.
You can do this by creating a form based on table Field. Just create it by pressing New in the Object Designer and add all fields to the form.
Put a filter on RelationTableNo (filter is the ID of the employee table).
If there are a lot of fields in that filter and the tables are filled, then that's probably the reason the Rename isn't fast.
Tino Ruijs
Microsoft Dynamics NAV specialist
Kine how can we achieve this?
Thanks.
It is just manual work and you need to have developer license (be a partner or have AB or SD license). If you do not know how to do that, than it will be better to not doing that and find someone who will do that for you...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
An other way is, store temporary, delete (without true), insert (without true) tempory back with new primary key.
After this u must modify all tables (and there records in an loop) which has an relation to the old empl. number.
To change the value of the empl. No, u can use the format function.
Regards
I think the solution Garak suggests, is the safest solution.
Tino Ruijs
Microsoft Dynamics NAV specialist