Error message:

iqbalmad
Member Posts: 180
Hi everyone
I have created a field Bar code on the Item table(27) of code 20.
On validate of the Bar code field, i have put below codes:
ItemCrossReference.SETCURRENTKEY("Item No.","Cross-Reference No.");
IF ItemCrossReference.GET(Rec."No.",xRec."Barcode No.") THEN
BEGIN
RENAME(ItemCrossReference."Item No.",ItemCrossReference."Cross-Reference No.",Rec."No.",Rec."Barcode No.");
END
ELSE
BEGIN
ItemCrossReference.INIT;
ItemCrossReference."Item No.":="No.";
ItemCrossReference."Cross-Reference Type":=ItemCrossReference."Cross-Reference Type"::"Bar Code";
ItemCrossReference."Cross-Reference No.":= "Barcode No.";
ItemCrossReference.INSERT(TRUE);
END;
The insert works fine, but when i want to change a Bar code, it gives me an error "Overflow under type conversion of Code to Code"
Can you please help, why the rename function is not working.
Thanks in advance.
I have created a field Bar code on the Item table(27) of code 20.
On validate of the Bar code field, i have put below codes:
ItemCrossReference.SETCURRENTKEY("Item No.","Cross-Reference No.");
IF ItemCrossReference.GET(Rec."No.",xRec."Barcode No.") THEN
BEGIN
RENAME(ItemCrossReference."Item No.",ItemCrossReference."Cross-Reference No.",Rec."No.",Rec."Barcode No.");
END
ELSE
BEGIN
ItemCrossReference.INIT;
ItemCrossReference."Item No.":="No.";
ItemCrossReference."Cross-Reference Type":=ItemCrossReference."Cross-Reference Type"::"Bar Code";
ItemCrossReference."Cross-Reference No.":= "Barcode No.";
ItemCrossReference.INSERT(TRUE);
END;
The insert works fine, but when i want to change a Bar code, it gives me an error "Overflow under type conversion of Code to Code"
Can you please help, why the rename function is not working.
Thanks in advance.
0
Comments
-
1) you are trying to rename the current record in T27.
2) You don't have to specify WHICH fields when you use RENAME, just the values
SO i think your code should be :... IF ItemCrossReference.GET(Rec."No.",xRec."Barcode No.") THEN ItemCrossReference.RENAME(Rec."No.",Rec."Barcode No.") else begin ...
P.S. put your code between code tage to make it better readable0 -
iqbalmad wrote:Error message:
iqbalmad, please search the forum, this topic has been discussed many times before.
http://www.mibuso.com/forum/search.php?keywords=error+message&terms=all&author=&sc=1&sf=all&sk=t&sd=d&sr=topics&st=0&ch=300&t=0&submit=Search+the+forumDavid Singleton0 -
You can only use the GET command with the primary key and you have to state all the fields in the primary key.0
-
Torben R. wrote:You can only use the GET command with the primary key and you have to state all the fields in the primary key.
That's not entirely true. You need to use the fields startign from the beginning of the primary key, but if you don't state them all the GET will not error. It will just retrun the first record that meets the filter. Effectively behaving like a FINDFIRST.There are no bugs - only undocumented features.0 -
bbrown wrote:You need to use the fields startign from the beginning of the primary key, but if you don't state them all the GET will not error. It will just retrun the first record that meets the filter. Effectively behaving like a FINDFIRST.
As far as I'm concerned that is a bug and the compiler should not accept this. At least there should be a run time error.0 -
DenSter wrote:bbrown wrote:You need to use the fields startign from the beginning of the primary key, but if you don't state them all the GET will not error. It will just retrun the first record that meets the filter. Effectively behaving like a FINDFIRST.
As far as I'm concerned that is a bug and the compiler should not accept this. At least there should be a run time error.
I absolutely agree that this should be considered a bug. But I also think it is something a developer needs to be aware of. If you don't specify all the primary key fields, the GET will not error. It will just return the first record that satisfies the values you provided. Which may not be the record you expected. Therefore resulting in unwanted behavior.There are no bugs - only undocumented features.0 -
DenSter wrote:bbrown wrote:You need to use the fields startign from the beginning of the primary key, but if you don't state them all the GET will not error. It will just retrun the first record that meets the filter. Effectively behaving like a FINDFIRST.
As far as I'm concerned that is a bug and the compiler should not accept this. At least there should be a run time error.
Denster have you never written
GLSetup.GET;
Are you saying that is a bug?
BTW I would rather see GLSetup.GET(''); but I think it is so entrenched in C/AL it isn't going to be fixed.David Singleton0 -
That's not entirely true. You need to use the fields startign from the beginning of the primary key, but if you don't state them all the GET will not error. It will just retrun the first record that meets the filter. Effectively behaving like a FINDFIRST.
If that is true I will get the message 1001 in a CRONUS when I executeWITH SalesHeader DO BEGIN GET("Document Type"::Order); MESSAGE("No."); END;
but I get an error:The Sales Header does not exist.
Indentification fields and values:
Document Type='Order',No.=''0 -
very interesting refresher course :-)
so, HOW should i have written the code?0 -
The primary key is
Item No.,Variant Code,Unit of Measure,Cross-Reference Type,Cross-Reference Type No.,Cross-Reference No.
so I would do it something likeIf ItemCrossReference.GET(“No.”,’’,”Base Unit of Measure”, ItemCrossReference."Cross-Reference Type"::"Bar Code”,’’, xRec."Barcode No.") THEN BEGIN ItemCrossReference2 := ItemCrossReference; ItemCrossReference2 := "Barcode No."; ItemCrossReference2.INSERT; ItemCrossReference.DELETE; END ELSE BEGIN…
(I don't like to rename if it's not absolutely necessary.)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