UpdateBuffer.SETRANGE("Primary Key",TRUE); IF NOT UpdateBuffer.FINDFIRST THEN ERROR(STRSUBSTNO('No primary keys found for table %1.',UpdateBuffer."Table No.")); RecRef.OPEN(UpdateBuffer."Table No.",FALSE,COMPANYNAME); RecRef.INIT; REPEAT FieldRef := RecRef.FIELD(UpdateBuffer."Field No."); EVALUATE("Var",UpdateBuffer."Field Value"); FieldRef.VALIDATE("Var"); UNTIL UpdateBuffer.NEXT = 0; UpdateBuffer.SETRANGE("Primary Key",FALSE); IF UpdateBuffer.FINDFIRST THEN REPEAT //now get each field ref and set the value accordingly FieldRef := RecRef.FIELD(UpdateBuffer."Field No."); EVALUATE("Var",UpdateBuffer."Field Value"); FieldRef.VALIDATE("Var"); UNTIL UpdateBuffer.NEXT = 0; //call a modify here on the rec ref RecRef.INSERT(TRUE); RecRef.CLOSE;
Comments
Not sure what you are trying to acheive with the code. I'm guessing the you are hoping to update a number of records but "recref" variable is on the initial record. There is not MODIFY and only one INSERT. On the face of it, I think you are over complicating it. A second UpdateBuffer would be more normal.
Can you explain what you want to acheive
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html