Relocation of Employee

zulq
Member Posts: 204
Hi,
Got an employee table and other dependent tables example of which is payments. The problem is that some employees are registered twice with different employee numbers and they have multiple payments on the payments table with both employee numbers.
Now I want:
1. form which will select all employee numbers -no problem doing this.
2. Give user options to choose which account to use as the correct account -no problem doing this also.
3. Give user options to select all tables on which the rename will be applied.-Need help on this.
Any ideas please?
Got an employee table and other dependent tables example of which is payments. The problem is that some employees are registered twice with different employee numbers and they have multiple payments on the payments table with both employee numbers.
Now I want:
1. form which will select all employee numbers -no problem doing this.
2. Give user options to choose which account to use as the correct account -no problem doing this also.
3. Give user options to select all tables on which the rename will be applied.-Need help on this.
Any ideas please?
Few years ago we were not existing and few years to come we would be in the grave! So what will benefit us in the grave?
0
Answers
-
If you are looking for table relations from your employee table, you can use the Field table as a reference; where the "Relation TableNo" = your table ID, and use this for your list.
There are some ways of "merging" accounts by deleting one record and renaming the other into it; but obviously this is pretty dangerous if you make a mistake, as it can't be reversed... it's not in my opinion recommended.
I'm not sure I completely understand the question though, more than likely it is because I'm having a case of the monday's...-Lavin
"Profanity is the one language all programmers know best."0 -
Hi,
Try this and if it work manually then you can code it, as it will depend in the table relations:
e.g. Employee A and B are the duplicates and you want to keep Employee A
1. Delete Employee A master record :!: (without running the ONDELETE trigger)
2. Rename Employee B to employee A ( which should rewrite the depending data)
This assumes that the master record for A and B are the same.0 -
Hi DaveT,
the problem with your approach is that when A is deleted all of A's corresponding transactions will be deleted. As a result the renaming has to take place first then delete the unwanted record i.e. in this instance A.
I want an option to select all tables the user wants the rename to be applied. Rename the transactions on those tables and then deleted A if user wants to.Few years ago we were not existing and few years to come we would be in the grave! So what will benefit us in the grave?0 -
HiDaveT wrote:Delete Employee A master record (without running the ONDELETE trigger)
You will find that the transactions are deleted in the ONDELETE trigger on the master record. If this is by-passed (either temporarily comment out the code or use DELETE( FALSE ) ) you should be ok.0 -
Hi,
Got it working now but want the details of A to maintain instead losing them since that will be the employee to keep.
To be more precise I can delete A with all details and rename B to A. However the details of A has to be maintained as that is the ID maintain
Any ideas please?Few years ago we were not existing and few years to come we would be in the grave! So what will benefit us in the grave?0 -
Hi,
Before the delete of A transfer the details to B and modify the record. This will overwrite B and after the rename A will look unchanged.0 -
Is there any way I can copy all the field values or assign them without having to do it statically.
I want it done in a way that if a new field is added to the table I don't need to update the code.Few years ago we were not existing and few years to come we would be in the grave! So what will benefit us in the grave?0 -
Hi,
Yes, simply save the employee B code then use
EmpBRec := EmpARec;
EmpBRec.code := SavedCode;
Where EmpBRec and EmpARec are variables of type record.0 -
Hi DaveT below is my code but it's not working. EmpRecB is not being updated with the fields of EmpRecA
empRecA.SETCURRENTKEY("No."); empRecB.SETCURRENTKEY("No."); empRecA.SETRANGE("No.",OldNumberToMaintain); empRecB.SETRANGE("No.",NewNumberToChange); IF empRecA.FIND('-') AND empRecB.FIND('-') THEN BEGIN empRecB := empRecA; empRecB.MODIFY(TRUE); END; IF empRecA.FIND('-') THEN BEGIN empRecA.DELETE; END; IF empRecB.FIND('-') THEN BEGIN empRecB.RENAME(OldNumberToMaintain); END;
Few years ago we were not existing and few years to come we would be in the grave! So what will benefit us in the grave?0 -
Hi,
Yuo forgotDaveT wrote:EmpBRec.code := SavedCode;
or in your code it will be
EmpBRec.code := NewNumberToChange;
before the modify.0 -
Thanks DaveT, it's working now.Few years ago we were not existing and few years to come we would be in the grave! So what will benefit us in the grave?0
-
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