Dataport import problem

tompynation
Member Posts: 398
Hi, i created a dataport which reads a csv file, and insert the records in to the Purchase Price table.
The following records are in my csv file and should be imported:
Enabled SourceExpr StartPos Width
Yes "Vendor No." 0 0
Yes "Item No." 0 0
Yes "Vendor Item No." 0 0
Yes "Unit of Measure Code" 0 0
Yes "Currency Code" 0 0
Yes "Direct Unit Cost" 0 0
Yes "Starting Date" 0 0
Yes "Ending Date" 0 0
Now, the problem is that "Vendor Item No." is not a field inside the Purchase Price Table, so i added this field as a C/AL Global...
Now when the csv file dont contains an "Item No." then the "Vendor Item No." will be filled in... with this "Vendor Item No." i should select the corresponding "Item No." form the table "Item Cross-Reference"
So i wrote this code which should perform the lookup of the corresponding "Item No.":
OnBeforeImportRecord:
IF "Item No." = '' THEN BEGIN
itemCrossRefRec.SETRANGE("Cross-Reference Type No.", "Vendor No.");
itemCrossRefRec.SETRANGE("Cross-Reference No.", "Vendor Item No.");
IF itemCrossRefRec.FIND THEN BEGIN
"Item No." := itemCrossRefRec."Item No.";
MESSAGE('Opgehaald Item No.: ' + FORMAT("Item No."));
END;
END;
The problem now is that the values of the Fields "Vendor No." and "Vendor Item No." are zero in side this method :?:
How can i get the values from my csv corresponding to the empy "Item No." ?
The following records are in my csv file and should be imported:
Enabled SourceExpr StartPos Width
Yes "Vendor No." 0 0
Yes "Item No." 0 0
Yes "Vendor Item No." 0 0
Yes "Unit of Measure Code" 0 0
Yes "Currency Code" 0 0
Yes "Direct Unit Cost" 0 0
Yes "Starting Date" 0 0
Yes "Ending Date" 0 0
Now, the problem is that "Vendor Item No." is not a field inside the Purchase Price Table, so i added this field as a C/AL Global...
Now when the csv file dont contains an "Item No." then the "Vendor Item No." will be filled in... with this "Vendor Item No." i should select the corresponding "Item No." form the table "Item Cross-Reference"
So i wrote this code which should perform the lookup of the corresponding "Item No.":
OnBeforeImportRecord:
IF "Item No." = '' THEN BEGIN
itemCrossRefRec.SETRANGE("Cross-Reference Type No.", "Vendor No.");
itemCrossRefRec.SETRANGE("Cross-Reference No.", "Vendor Item No.");
IF itemCrossRefRec.FIND THEN BEGIN
"Item No." := itemCrossRefRec."Item No.";
MESSAGE('Opgehaald Item No.: ' + FORMAT("Item No."));
END;
END;
The problem now is that the values of the Fields "Vendor No." and "Vendor Item No." are zero in side this method :?:
How can i get the values from my csv corresponding to the empy "Item No." ?
0
Answers
-
Move your code to the OnAfterImportTrigger. The record is read in this trigger and not OnBeforeImportTrigger.
Also in OnBeforeImportRecord add:
CLEAR('Your Record VAR')There are no bugs - only undocumented features.0 -
if i move my code, to the on AfterImportRec
I get an error warning me 'The field cannot be empty, please enter a value'
The field they are talkin about is the 'Item No.'
Which should be filled up with the code that i moved...0 -
Solved the problem
OnAfterImportRecord:
IF gv_ItemNo = '' THEN BEGIN
itemCrossRefRec.SETRANGE("Cross-Reference Type No.", "Purchase Price"."Vendor No.");
itemCrossRefRec.SETRANGE("Cross-Reference No.", gv_ItemVendorNo);
IF itemCrossRefRec.FIND('-') THEN BEGIN
"Purchase Price"."Item No." := itemCrossRefRec."Item No.";
END;
END
ELSE BEGIN
"Purchase Price"."Item No." := gv_ItemNo;
END;
IF NOT "Purchase Price".INSERT THEN
"Purchase Price".MODIFY;
And i made the "Item No." as a C/AL global to instead of a dataport field0
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