Information on COPY function

Nitesh
Nitesh Member Posts: 43
I want more information on how to use COPY function and its use.I have tried it out but didnt get desired result.

Comments

  • tinoruijs
    tinoruijs Member Posts: 1,226
    You could search for COPY in the C/SIDE reference guide (Design mode: F1)
    You'll find a copy for records and a copy for files.

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • Nitesh
    Nitesh Member Posts: 43
    i had seen that. It doesnt work atall.
  • tinoruijs
    tinoruijs Member Posts: 1,226
    Nitesh wrote:
    i had seen that. It doesnt work atall.

    Can you describe what you are trying to do? Maybe show some code and errors?

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • Nitesh
    Nitesh Member Posts: 43
    im trying something like this,

    Table1.COPY(Table2);

    copying records from table2 to table1 and its giving me error like,
    'Copying all filters at once can only be done between records belonging to the same table. Copy the necessary filters one at a time.'
  • todro
    todro Member Posts: 117
    Nitesh wrote:
    im trying something like this,

    Table1.COPY(Table2);

    copying records from table2 to table1 and its giving me error like,
    'Copying all filters at once can only be done between records belonging to the same table. Copy the necessary filters one at a time.'

    The reason is, that copy is copying the filters too and they do not match, obviously you are trying to copy from one table to another, e.g. 18 to 21, that's not possible. The records have to be from the same source table.

    If fieldnumbers are the same, you can use transferfields to copy identical fields from one record to another. If the tables are totally different, you have to assign every field manually.
    Torsten
    MCP+I, MCSE NT, Navision MCT (2004,2005)
  • Nitesh
    Nitesh Member Posts: 43
    If the tables are totally different, you have to assign every field manually.



    i didnt get how it can b done..but anyways thank you..
  • todro
    todro Member Posts: 117
    Nitesh wrote:
    If the tables are totally different, you have to assign every field manually.



    i didnt get how it can b done..but anyways thank you..

    Maybe I got you wrong.

    with "manually" I meant a normal assignment to the record fields, e.g.
    SalesLine....
    SalesLine.Description := Item.Description;
    SalesLine."No." := Item."No.";
    SalesLine.insert;
    

    etc.
    Torsten
    MCP+I, MCSE NT, Navision MCT (2004,2005)
  • SharonVelankanni
    SharonVelankanni Member Posts: 9
    you can try like this

    table1 - record data type
    table2 - record data type
    if table2.find('-') then
    repeat
      table1.transferfields(table2);
      table1.insert;
    until table2.next = 0;
    

    provided, your table2's field numbers should match with your table1's field numbers and their data type should also match
    Regards,
    Sharon
  • arindom
    arindom Member Posts: 52
    "COPY (Record)
    Use this function to copy a record from a C/SIDE table. All filters, marks, and keys are included in the copy.

    Record.COPY(FromRecord)"


    The COPY function copy all the filters from table2 to table1 .So If the tables or table fields are not same then COPY are not working .If u want to assign two differnt field value then if the field IDs and data type both tables are same then use TRANSFERFIELD function .otherwise assign manualy all field from table2 to table1 .