Hi everyone,
I need to change some properties of my items.The problem is that I've already worked with them so I can not change the properties directly.
I decided to make a copy of the items, change the properties in the copied item and then block the original one...
The code I used in the OnAfterGetRecord of my report is the following:
CurrentItem.GET("No.");
IF CurrentItem.FINDFIRST THEN
BEGIN
CurrentItem.RENAME('C_'+CurrentItem.Description);
CopyItem.COPY(CurrentItem);
CopyItem.Description:= COPYSTR(CopyItem.Description, 2,STRLEN(CopyItem.Description)-2) ;
CopyItem."Costing Method":=3;
CurrentItem.Blocked := TRUE;
CopyItem.INSERT;
END;
The code generates the following error:
The Item No. already exists.
What shall I do???
Comments
Chn
The instruction generating error is:
How is that???
The first line retrieves the Item you want. The second line moves to the first item in your item table. Unless you are trying to update the first item in your table, it is pointing to the wrong record. If you are, then the two lines are redundant.
Step thru "line by line" to see what it is doing,
What shall I do to modify the description not the No???
and not copy an item as per you post name?
description := mynewdescription;
modify;
why would you want to add a "C_" to the beginning of each description?
http://www.BiloBeauty.com
http://www.autismspeaks.org
By the way, i tried to change the code with modify...It didn't work and the description of the item didn't change...
is item the main dataitem?
changing the description alone will not create a copy of the item.
the key field is "no."
you need new item no for each item copy
what's your thinking behind "FINDFIRST"?
If item is your dataitem and currentitem is a variable type record for the item table then it will run thru the records anyway.
http://www.BiloBeauty.com
http://www.autismspeaks.org
No it won't because the "No." field already has a value.
//IF "No." = '' THEN BEGIN -- You do not need to check this though
GetInvtSetup;
InvtSetup.TESTFIELD("Item Nos.");
NoSeriesMgt.InitSeries(InvtSetup."Item Nos.",<<can be the same as the last argument>>,0D,<<your variable where you want the next number to come>>,<<pass the default number series code here>>);
//END;
Chn
OK. Missed that. But not sure I'd assume he's using a number series to generate new item numbers.
Here is the code:
I tested it for one item or many items, it works just fine...
The problem is when I try to run it for a Gen. Prod. Posting Group...I get the following error message:
I tried to debug the code...It seems like it is running forever...
Why is that???What shall I do???