assigning record variables

EugeneEugene Member Posts: 309
what exactly an assignment of a record variable to record variable means

for example in "Bank Account Ledger Entry"OnAfterGetRecord trigger i find the following code:

BankAccLedgEntry2 := "Bank Account Ledger Entry";
WITH BankAccLedgEntry2 DO BEGIN
...
END;

is BankAccLedgEntry2 another table-cursor to the same undelying table with fields, filters assigned from original one or does it become another reference to the same table-cursor ?

C/SIDE courseware explains the situation with codeunit variables but is very vague on this issue with Record variables.
Thank you for your help

Comments

  • KowaKowa Member Posts: 925
    BankAccLedgEntry2 := "Bank Account Ledger Entry";
    will not copy the filters ( just the field values), you need to use the COPY function for this, or a separate COPYFILTERS after the assignment.
    You can step through BankAccLedgEntry2 independently, performing any action needed, while leaving the cursor on "Bank Account Ledger Entry" untouched, so it should be a different table-cursor.
    Kai Kowalewski
  • ara3nara3n Member Posts: 9,257
    I always viewed it the same way as using transferfields only for the same table
    BankAccLedgEntry2.transferfields("Bank Account Ledger Entry");

    It doesn't copy filters, when you do assignment. It basically creates another recordset pointing to the same record. It is a different version so if you modify with BankAccLedgEntry2.
    and then modify "Bank Account Ledger Entry", you'll get another user modifeid error.

    To copy all the filters use
    BankAccLedgEntry2.copy("Bank Account Ledger Entry");

    Copy will have the filters. but still is a different version.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.