Options

how to transfer a form details to another form?

Jacob1227Jacob1227 Member Posts: 128
how to transfer a form details to another form even one field has different data type in each tables?

Answers

  • Options
    Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    tableA.Field1 := tableB.Field1;
    tableA.Field2 := tableB.Field2;
    ...and so on.

    Skip fields which do not match.

    Wrap the code in a function so you can reuse it. Even if you don't plan to re-use it still wrap it in a separate function - it will make your code more readable,
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • Options
    Jacob1227Jacob1227 Member Posts: 128
    edited 2017-12-13
    thanks for this.Can u please elaborate the coding ? and Which trigger i have to put this code?
  • Options
    Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    There is not much philosophy or science there. It is just a series of assigment statements wrapped in a function, nothing more.

    When you call ToRecord.TRANSFERFIELDS(FromRecord) the system copies fields from FromRecord to ToRecord. The idea is to build a function doing the almost the same but skipping unwanted fields. Since the TRANSFERFIELDS is called on a destination record (ToRecord.REANSFERFIELDS...) then to make my custom copy fields function similar I am also defining it on source table.

    I am also trying to stick to specific naming convention, and call my function CopyFromSomeRec() so furtehr down the code I can clearly see what it is doing
    ToRecord.CopyFromRecordA(RecordA)

    If the function is suposed to copy fields from some record A to record B, then on table B (destination table) I would create function CopyFromRecordA, with RecordA as a parameter, and inside this function put a series of assignments.

    Just note that both TRANSFERFIELDS and a function assigning field values is not supposed to insert anyting into the database. Both are supposed to do in-memory copy - that's it. If you want to make a copy of record A into record B in the database you need to insert that copy into the DB
    RecB.CopyFromRecordA(RecA);
    RecB.INSERT;
    


    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Sign In or Register to comment.