Transferfields

mxcmxc Member Posts: 42
edited 2003-09-07 in Navision Attain
As we all know, transferfields copies fields based on the Field No. property of the fields. My problem is the following: I want to transfer the fields from table 38 (purchase header) to table 5109 (purchase header archive), but I have two fields where the numbers do not correspond and of course, I´m getting an error...
How can I solve this problem in a simple way?
Yesterday I tried to change the field nos. and to make a long story short, I had to restore a backup...
Regards,

Manuel Xavier

Comments

  • nunomaianunomaia Member Posts: 1,153
    I only see two ways


    - Using dataports

    - Using fieldref and FIELDEXIST
    discover the fields, and store that in a vector.

    copy all fields from table 38 to 5109
    (simulating transferfields)

    Nuno Maia
    Nuno Maia

    Freelance Dynamics AX
    Blog : http://axnmaia.wordpress.com/
  • StephenGStephenG Member Posts: 99
    Hi Manuel
    I don't think there is an easy way to solve this :(.

    I think the simplest solution is to create a function within a codeunit or even on one of the two mentiond tables.

    In this function you will individually assign each field from record from Table 38 to the corresponding field in table 5109. The function would only need one run time parameter Rec Table38 and a local Variable of rec for Table 5109.

    This way you can call the function from anywhere :) .
    Answer the question and wait for the answer.
  • mxcmxc Member Posts: 42
    I compared the Field No. of all the fields in both tables and found one field 5043, that in one table is an integer and in the other is boolean. Why does TRANSFERFIELDS works with this and doesn't work with my fields??
    Regards,

    Manuel Xavier
  • nunomaianunomaia Member Posts: 1,153
    FROM Online Help

    The fields must have the same data type for the copying to succeed (text and code are convertible, other types are not.
    Nuno Maia

    Freelance Dynamics AX
    Blog : http://axnmaia.wordpress.com/
  • mxcmxc Member Posts: 42
    I just read on the navision attain C/AL Programming manual that: the integer value is not interchangeable with the constant of TRUE or FALSE.
    Regards,

    Manuel Xavier
  • StephenGStephenG Member Posts: 99
    Hi

    From OnLine Help 'Integers'
    In addition to representing whole numbers in this range, you can use integers to represent boolean values. For boolean values, -1 represents TRUE and 0 represents FALSE.

    This is why the Integer / Boolean transfer works
    Answer the question and wait for the answer.
  • lakshmivallurulakshmivalluru Member Posts: 168
    Hi mxc,

    Transferfields will transfer fields from one table to other if the field no and the datatype matches.Firstly to sort ur problem out u can say

    PurchaseHeaderArchive.transferfields(PurchaseHeader);
    PurchaseHeaderArchive.newfield1 := PurchaseHeader.newfield1;
    PurchaseHeaderArchive.newfield2 := PurchaseHeader.newfield2;

    where newfields doesnot match the number.

    Secondly,ur question was y field no 5043 (boolean in table 38 and integer in table no 5109) is not giving a problem though they r different datatypes?

    Reason is you can assign a boolean or option values to integer.
    similarly a text can take code.

    hope this helps.
    LR
  • eromeineromein Member Posts: 589
    export all objects as text, import all objects as text (all objects are now NOT compiled), rename field, compile all objects, smile!
    "Real programmers don't comment their code.
    If it was hard to write, it should be hard to understand."
Sign In or Register to comment.