Dynamics Nav Logic Programming


I want to ask a simple question about the Nav logic programming .

In CodeUnit (23) : Item Jnl.-Post Batch ,The standard use a record variable to copy rec and after the code processing ,it assign ItelJnlLine to Rec.

My questions are :

Why the system use this logic ?Why don't use directly Rec?

What the difference between a simple assign and ToRecord.Copy(FromRecord)?

Thank you.

  • Hi Amine,
    To your first question, why not use Rec directly? They are "simply" transferring the local Rec variable to a global ItemJnlLine variable used throughout the codeunit. If they where not updating Rec again before exiting, then the VAR would not have been updated in the calling object.

    The COPY function copies either to the current record or the specified record. COPY(Rec) would just copy itself. The "current" record can also be "over written" with a "WITH RecordVar DO" statement.
  • In reply to Erik P. Ernst:

    Thank you very much for the prompt reply.