Now I want to use a report and rename many item no. For example: original Item No: -*** such as AA-00001 BB-00002… and I want to delete the character ‘-’ and change them to AA00001 or BB00002 The below is my report design: 1. add item DataItem 2.Item-OnAfterGetRecord IF NOT( (STRLEN(“No.”)=8) AND (COPYSTR(“No.”,3,1)=’-’)) THEN CurrReport.SKIP ELSE BEGIN Item.LOCKTABLE; OldItemNo := Item.“No.”; NewItemNo := COPYSTR(OldItemNo,1,2)+COPYSTR(OldItemNo,4,5); Item.RENAME(NewItemNo); COMMIT; END; but when I run the report, it seems only the first record was renamed and the rest records can’t be renamed during the same report running. Why? Any good ideas? Thank in advance
Hi P H, It’s probably because your report is using the primary key (“No.”). Either 1) Use another key. or 2) Make a copy of the record to a another variable before renaming.
Seems like you are renaming the same item in the loop. Use a different Item variable. for Example: Item2.get(“No.”) Item2.rename(NewItemNo); commit; Naveen Jain
Thanks, sv. Your methods works well. I always can find the answer in the forum.