Import txt file and autonumber

ROBO
Member Posts: 39
I want to import txt files with a dataport and then use autonumber. But the problem is when I use autoincrement in my table and there are more lines in the text file the line are overwritten. Can someone help me?
ThanX
ThanX
0
Comments
-
What kind of table are you populating?
I think you will either need to write some code or add the number to your importfile.0 -
Yes more info Needed...
But you can do
OnPreDataItem()
"Line No." := 1;
OnAfterImportRecord()
"Line No." := "Line No." + 1;
:?: :?: :?:0 -
ROBO wrote:I want to import txt files with a dataport and then use autonumber. But the problem is when I use autoincrement in my table and there are more lines in the text file the line are overwritten. Can someone help me?
ThanX
The autonumber field is integer with autoincrement. In the dataport i wrote some code:
IF msgInfo.FIND('+') THEN
msgInfo."Nr." := msgInfo."Nr." + 1
ELSE
msgInfo."Nr." := 1;
INSERT(TRUE);0 -
="ROBO
The autonumber field is integer with autoincrement. In the dataport i wrote some code:
IF msgInfo.FIND('+') THEN
msgInfo."Nr." := msgInfo."Nr." + 1
ELSE
msgInfo."Nr." := 1;
INSERT(TRUE);
1) What trigger are you using.
2) Everytime it hits "ELSE" the number is "1" overwriting the previous "1" are you sure it's finding anything?
3) What table are you trying to bring this into?0 -
Please remove the autoincrement. This is not a realy relicable function. We've had some problems with this in the past.0
-
Mark Brummel wrote:Please remove the autoincrement. This is not a realy relicable function. We've had some problems with this in the past.0
-
Navision invented no. series for this. Please use either this or use code like in the other navision entry tables.0
-
Savatage wrote:="ROBO
The autonumber field is integer with autoincrement. In the dataport i wrote some code:
IF msgInfo.FIND('+') THEN
msgInfo."Nr." := msgInfo."Nr." + 1
ELSE
msgInfo."Nr." := 1;
INSERT(TRUE);
1) What trigger are you using.
2) Everytime it hits "ELSE" the number is "1" overwriting the previous "1" are you sure it's finding anything?
3) What table are you trying to bring this into?
1) it's a dataport that must import text files (single line and multiline). After the import it delete the file.
2) I want to find the last number that is used
3) It is a self made table with "nr." as key (integer) this is the field i want the autonumber apply's to.
Thanx for your help0 -
Mark Brummel wrote:Please remove the autoincrement. This is not a realy relicable function. We've had some problems with this in the past.
But the field is a BigInteger, and not an integer.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
ROBO wrote:2) I want to find the last number that is used
3) It is a self made table with "nr." as key (integer) this is the field i want the autonumber apply's to.
Use this system:
Dataport - OnPreDataport():msgInfo.RESET; IF msgInfo.FIND('+') THEN intLastUsedNo := msgInfo."Nr.";
OnAfterImportRecord();intLastUsedNo += 1;
Like this, you do the read for the last one only once.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
We've had some strange SQL error that was caused by the autoincrement property. I don't remember precisely what the error was.0
-
Hi Alain,
It imports the txt file but the line's get overwritten when its a multiline txt file. Do you have a solution for that also?
Thanx a lot0 -
Mark Brummel wrote:We've had some strange SQL error that was caused by the autoincrement property. I don't remember precisely what the error was.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
ROBO wrote:Hi Alain,
It imports the txt file but the line's get overwritten when its a multiline txt file. Do you have a solution for that also?
Thanx a lotRegards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
I think your dataport is mixing up the variables, or it's not setting the number in the right trigger. To take the whole thing into your own hands, you can import your text file into variables instead of the fields of your table directly, and then write the code to insert the records using the values of the variables.0
-
I don't insert it myself i use the dataport fields is it possible with this also?0
-
DenSter wrote:I think your dataport is mixing up the variables, or it's not setting the number in the right trigger. To take the whole thing into your own hands, you can import your text file into variables instead of the fields of your table directly, and then write the code to insert the records using the values of the variables.
I never did this is there an example for this?0 -
where you enter fields into the dataport fields editor, you can also enter variable names. Then in the OnAfterImportRecord trigger you handle the values.0
-
ROBO wrote:DenSter wrote:I think your dataport is mixing up the variables, or it's not setting the number in the right trigger. To take the whole thing into your own hands, you can import your text file into variables instead of the fields of your table directly, and then write the code to insert the records using the values of the variables.
I never did this is there an example for this?
This is what I did on post: (As an example)
http://www.mibuso.com/forum/viewtopic.php?t=9631
I set it before anything happens & bring it back later
OnAfterImportRecord()Code:
Internet_Cust_Orig_Item := "No.";
Item.GET("Sales Line"."No.");
IF Item.Blocked THEN
BEGIN
"Sales Line"."No." := '99904';
END;
"Sales Line".VALIDATE("No.");
"Sales Line"."Qty. Ordered" := Internet_Cust_Qty;
"Sales Line".Quantity := Internet_Cust_Qty;
"Sales Line".VALIDATE("Qty. Ordered");
"Sales Line"."EDI Unit Price" := Internet_Price;
"Sales Line"."EDI Item Cross Ref." := Internet_Cust_Orig_Item;
Importing the data into vaiables & then assigning them to it's proper Navision Field OnAfterImportRecord, as Denster stated, always solves my dataport problems0 -
Denster & Savatage and everybody Thanx for your help. The variabele does the trick.
ThanX again0 -
-
I had this problem, you need to add the following to the OnBeforeImportRecord() trigger of your Dataitem :
CLEAR(Rec);
Your autoincrement field will then work fine.
Jonathan0
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