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
0
Comments
- 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
Freelance Dynamics AX
Blog : http://axnmaia.wordpress.com/
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 .
Manuel Xavier
The fields must have the same data type for the copying to succeed (text and code are convertible, other types are not.
Freelance Dynamics AX
Blog : http://axnmaia.wordpress.com/
Manuel Xavier
From OnLine Help 'Integers'
This is why the Integer / Boolean transfer works
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.
If it was hard to write, it should be hard to understand."