Dear Friends,
I am trying to change the employee number(No.) field in the Employee card,when the number is changed the (No.) field in the Resource table should also change which is the primary key field of that table. i used the following code but i face an error when i try to change it for the second time and after that.
i gave this code in the No. (Onvalidate) of Employee Table
IF Rec."No." <> xRec."No." THEN BEGIN
lvFound := FALSE;
lvResource.RESET;
IF lvResource.FIND('-') THEN BEGIN
REPEAT
IF lvResource."No." = xRec."No." THEN BEGIN
lvResource.RENAME(Rec."No."); //some issue here
lvFound := TRUE;
END;
UNTIL (lvResource.NEXT = 0) OR (lvFound);
END;
the problem comes where RENAME is used. I tried giving commit and all but no use. it says "Another user has modified the definition of the Field Table after the activity was started. START AGAIN" and this same error keeps on coming when ever i click anyware or go to employee table. i need to start the navision window again.
One more thing this error occurs only when i use FINSQL, in local the rename works without any error. how to solve this.
Thanks and Regards
Vineeth.R
0
Comments
2) Renaming record which is used to loop through some record set is bad. After renaming, the cursor is in undeffined state and you can get into neverending loop or end the loop to early...
3) Which client version you are using?
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
if you change fields in a record which are in the filter, it is better to modify a second recordvariable with the same record. like following:
Regards
yes i tried to find the record and the renaming is working but only for the first record in the recordset found. its not renaming the rest of the record and coming out of the loop.Please help
here is my code in the employee Card forms "no." fields onvalidate trigger, i want to rename the corresponding employee qualification's Employee number also.
lvEmployeeQualification.RESET;
lvEmployeeQualification.SETRANGE("Employee No.",xRec."No.");
IF lvEmployeeQualification.FIND('-') THEN BEGIN
MESSAGE(FORMAT(lvEmployeeQualification.COUNT));//12 records found
REPEAT
lvEmployeeQualification.RENAME(Rec."No.", lvEmployeeQualification."Line No.");//renamed first one then jumped out of the loop
UNTIL lvEmployeeQualification.NEXT = 0;
END;
Vineeth.R
CurrForm.Update(False);
(on the end of this code?)
Maybe it will help.
2) Just using second variable is not enough in newer versions of client. Best is to add records you need to rename into temporary table and then in loop go though this temp table and get real record and rename it... something like:
:!: And do not forget, that if you have correct TableRelation, you do not need any code to rename the records :!:
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
thank you . i was able to solve the issue using Temporary variable concept...
The same coding which now i gave in form's - "No." fields onvalidate worked well..
but when i tried the same in table's "no." fields onvalidate it gave me error saying
"another user modified the record. start again" why is it so??????
Vineeth.R
thank you . i was able to solve the issue using Temporary variable concept...
The same coding which now i gave in form's - "No." fields onvalidate worked well..
but when i tried the same in table's "no." fields onvalidate it gave me error saying
"another user modified the record. start again" why is it so??????[in finsql]
Vineeth.R