NAV 2015 - Copy a specific field of RecordRef

Dear all,

I  had a function to copy data from 1 recordref to another.

I'm trying to copy a specific field but it's not ok.

Here's my code, it does not show error but it copy all the other fields (with the default value!). Please share your ideas about this?

 

FOR i := 1 TO FromTableRef.FIELDCOUNT DO BEGIN

FromFieldRef := FromTableRef.FIELDINDEX(i);

IF FromFieldRef.NUMBER = 'specific Field ID here' then

BEGIN

ToFieldRef := ToTableRef.FIELDINDEX(i);

ToFieldRef.VALUE := FromFieldRef.VALUE;

END;

END;

 

Thanks and best regards,

Parents
No Data
Reply
  • What I mean is you don't need to loop all the fields just to get one field.

    FromTableRef.OPEN(TableNo, FALSE, FromCompanyName);
    ToTableRef.OPEN(TableNo, FALSE, ToCompanyName);
    
    IF FromTableRef.FINDFIRST THEN
        REPEAT
            ToTableRef.INIT;
            FromFieldRef := FromTableRef.FIELDINDEX(SpecificField.FieldNo);
    		ToFieldRef := ToTableRef.FIELDINDEX(i);
    		ToFieldRef.VALUE := FromFieldRef.VALUE;
    		ToTableRef.MODIFY();
        UNTIL FromTableRef.NEXT = 0;
    
    ToTableRef.CLOSE;

Children
No Data
Related
Recommended