Hello everyone,
I want to rename records on Product Group table, field code(that is part of primary key), and i can not do it. I have made a codeunit with code:
ProductGroup.RESET;
ProductGroup.INIT;
IF ProductGroup.FINDFIRST THEN
REPEAT
ProductGroup.Code:= ProductGroup."Item Category Code" +'/' +ProductGroup.Code;
ProductGroup.MODIFY;
UNTIL ProductGroup.NEXT=0;
But when i execute it it stops on the firs record displaying a error:
The Product Group does not exist.
Identification fields and values:
Item Category Code= xxx, Code= xxx/yyy;
Any suggestion how to do this, with function because i have a lot of records there.
Thanks in advice!
:!:
0
Answers
Instead use RENAME.
See the code below;
ProductGroup.RESET;
IF ProductGroup.FINDFIRST THEN
REPEAT
if ProductGroup2.get(ProductGroup."Item Category Code",ProductGroup.Code) then
ProductGroup2.Rename("Item Category Code",ProductGroup."Item Category Code" +'/' +ProductGroup.Code);
UNTIL ProductGroup.NEXT=0
Improper use of FINDFIRST. Also why fetch records twice?
=D>
where primary key contains multiple fields and you are renaming field number 4 for example?
in my example working with 'analysis view entry'
it seems like after the rename it fails to find the next record due to resort?
Microsoft Certified Business Management Solutions Professional
Microsoft Certified Business Management Solutions Specialist
http://www.navisiontech.com
Microsoft Certified Business Management Solutions Professional
Microsoft Certified Business Management Solutions Specialist
http://www.navisiontech.com