Copy/Pasting a calculated field does not copy the calculation context (if≠PTO)
Operating system version
Description of the issue
Pasting a calculated field into a table does not paste the calculation context, rather it resets the calculation context to the PTO of the table.
Thus if a copied field has a calculation context which is not the PTO of the table, it breaks/stops working.
The error is in the PASTE function, as the calculation context IS PRESENT in the fmxmlsnippet on the clipboard. This is surely REALLY EASY for you to change, and would HELP IMMENSELY.
Please consider giving this bug a high priority, along with all clipboard bugs...
- BECAUSE this bug very frequently causes new developments to go unexpectedly wrong.
- BECAUSE it is quite easy to oversee this error
- BECAUSE developers do not expect copy/paste to not work in such a devastating way,
- BECAUSE no error is reported in the import.log file
- BECAUSE there are sometimes very good reasons (e.g. performance) for having calculations based on non-PTOs
- BECAUSE when a table has been migrated from a different file, the PTO may not be the TO you desire. In this case all newly created calculation fields have a non-PTO calculation context (AND IT IS NOT POSSIBLE without HUGE effort to change the tables PTO <= this is another issue)
Steps to reproduce the problem
1. Create a DB with two tables A and B.
2. Add some normal fields to both tables
3. Make a second TO "A 2" for table A and create a relationship to table B
A B >-----< A 2
4. Create a calculated field "Test" in Table A, change the calculation context to A 2 and in the calculation reference a field from TO "B"
5. Copy field Test
6. Paste field back into the same table
A field "Test 2" should be created with the calculation context "A 2"
A field "Test 2" has been created with the calculation context "A" (the PTO)
(Note: under some conditions I have also seen the calculation being commented out, because the referenced fields are no longer in related tables, but I have been unable to reproduce that behavior here today)
Exact text of any error message(s) that appear
Edit the field definitions after you have pasted fields.