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.
0
Comments
2) You don't have to specify WHICH fields when you use RENAME, just the values
SO i think your code should be : P.S. put your code between code tage to make it better readable
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+forum
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.
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.
RIS Plus, LLC
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.
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.
If that is true I will get the message 1001 in a CRONUS when I execute
but I get an error:
so, HOW should i have written the code?