IF ReasCode.FIND('-') THEN
REPEAT
IF COPYSTR(ReasCode.Code, 1, 2) <> 'PF' THEN BEGIN
NewCode := 'PF' + ReasCode.Code;
ReasCode.RENAME(NewCode);
END;
UNTIL ReasCode.NEXT = 0;
This is probably becuase you are using the primary key as the sorting for the loop. The renamed record will becomes the last record in the table, so next will be 0.
Example : say you have the codes 01, 02 and 03. Renaming the first one to PF01 will make the table 02, 03, and PF01. because you are still on the PF01 record, next will say it has reached the end of the table.
Create a New report.
Take one DataItem : Reason Code
and write two line code.... Reason Code - OnAfterGetRecord()
IF COPYSTR(Code,1,2) <> 'navuser1' THEN
RENAME('navuser1' +Code);
Or you can just copy all records into TEMP variable based on same table and then go through this table in loop and rename the records in real table...
if MyReasonRec.FINDSET then
repeat
MyTempReason := MyReasonRec;
MyTempReason.INSERT;
until MyReasonRec.NEXT=0;
if MyTempReason.FINDSETthen
repeat
MyReasonRec.GET(MyTempReason.Code);
MyReasonRec.RENAME('PK'+MyReasonRec.Code);
until MyTempReason.NEXT=0;
Do not forget that the MyTempReason is TEMPORARY variable. Of course, naming of the variables are just examples... ;-)
Comments
Could u explain in detail what u want to do?
If possible could u paste the sample code and the trigger name where u have done the coding...
Raja.B
REPEAT
IF COPYSTR(ReasCode.Code, 1, 2) <> 'PF' THEN BEGIN
NewCode := 'PF' + ReasCode.Code;
ReasCode.RENAME(NewCode);
END;
UNTIL ReasCode.NEXT = 0;
Example : say you have the codes 01, 02 and 03. Renaming the first one to PF01 will make the table 02, 03, and PF01. because you are still on the PF01 record, next will say it has reached the end of the table.
Create a New report.
Take one DataItem : Reason Code
and write two line code....
Reason Code - OnAfterGetRecord()
IF COPYSTR(Code,1,2) <> 'navuser1' THEN
RENAME('navuser1' +Code);
Do not forget that the MyTempReason is TEMPORARY variable. Of course, naming of the variables are just examples... ;-)
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.