How to Determine if data to be imported does not exist?
zulq
Member Posts: 204
I have a csv file which contains list of employees. This list is imported on periodic bases. These data however sometimes changes. I want be able to compare the data to be imported to the existing data. If an employee exists in the database but is not in the import list it should be marked inactive/terminated. How do I compare the existing data to the list on the file to be imported?
Thanks.
Thanks.
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
Comments
-
One way is to have a "Date Modified" field. If the CSV has that Employee then update the "Date Modified". Then later you can easily filter on that field to see which one's were & were not updated.0
-
I mean I need to do this while importing for example comparing the unique employee no. on the import against unique employee no. on the existing data (nav table).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
-
You can also create a temporary record variable and insert all the records from the file into temporary record.
Then at the end loop through the employee record and see if it exists in Temporary record, if it doesn't then you can expire that employee0 -
How is it imported? using a dataport?0
-
Sorry was away. Yes it is imported using a dataport.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
-
Just follow the suggestion I had written above. use temp record.0
-
Hi Rashed,
I am trying to implement your suggestion but it's not working. Below is the code am using:emp.SETCURRENTKEY("No."); temp.SETCURRENTKEY("No."); IF emp.FIND('-') THEN BEGIN REPEAT IF temp.FIND('-') THEN BEGIN REPEAT IF NOT temp.GET(emp."No.") THEN BEGIN MESSAGE('no. '+'%1'+ emp."No.",' + does not exist'); emp.Status := emp.Status::Inactive; emp.MODIFY(TRUE); END; UNTIL temp.NEXT = 0; END; UNTIL emp.NEXT = 0; END;Am I missing something?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 -
WOW these are some complex solutions here, how about doing it the simple way*.
Create a new field in the employee card "Active Employee"::Boolean.
In the dataport add ONE LINE OF CODE:"Active Employee" := TRUE;
done.
* PS what ever happened to the old Navision logo "The Beauty Of Simplicity"David Singleton0 -
Hello You have a bug in your code.
IF emp.FIND('-') THEN BEGIN REPEAT IF NOT temp.GET(emp."No.") THEN BEGIN emp.Status := emp.Status::Inactive; emp.MODIFY(TRUE); END; UNTIL emp.NEXT = 0;
I'm assuming that on onaftergerimportrecord you are populating Temp record.0 -
you can also do what David has suggested, but instead use the current field Status.
On predataItem
Emp.modifyall (status,Status::Inactive);
On afterimportRecord add code to change the status to active.
validate(status,Status::Active);0 -
I did as you guys suggested but still after the import all employees are set to inactive.
OnPreDataItem:emp.SETRANGE(PaymentMode,PaymentMode::Wages); emp.MODIFYALL(Status,Status::Inactive);
Then on AfterImportRecord:VALIDATE(Status,Status::Active);
But still the status is inactive for all employees.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 -
It's working partially but employees who are not in paymentmode::wages are also set to inactive which should not be the case. That's why I put the the setrange there before deactivating everyone. Also if an employee is in the data to be imported but not in the employee table it should be inserted.
Thanks.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 -
Everything is working now except inserting record into table if it doesn't exist.
Any help 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 -
can you export your dataport as text and paste it in here?0
Categories
- All Categories
- 73 General
- 73 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 333 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

