Tech Tip: Copy and Pasting Fields
PRODUCT: 4D | VERSION: 11.4 | PLATFORM: Mac & Win
Published On: September 17, 2009
In 4D v11 SQL, fields can be copied and pasted within the Structure Editor. Copying fields places the fields in the Clipboard in XML. Here is an example,
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE base SYSTEM "https://www.4d.com/dtd/2007/base.dtd" >
<base>
<table name="FieldContainer" uuid="B1A7E560E5AC4DE09A87C04270054E99">
<field name="ID" uuid="BC489F467E204BFF9B160471A47BB02A" type="4" never_null="true">
<field_extra visible="false"/>
</field>
<field name="name" uuid="E08A72C610604AA1A8DC35EF67265B17" type="10" never_null="true">
<field_extra/>
</field>
</table>
</base>
<!DOCTYPE base SYSTEM "https://www.4d.com/dtd/2007/base.dtd" >
<base>
<table name="FieldContainer" uuid="B1A7E560E5AC4DE09A87C04270054E99">
<field name="ID" uuid="BC489F467E204BFF9B160471A47BB02A" type="4" never_null="true">
<field_extra visible="false"/>
</field>
<field name="name" uuid="E08A72C610604AA1A8DC35EF67265B17" type="10" never_null="true">
<field_extra/>
</field>
</table>
</base>
What happens when the fields are pasted depends on what is currently selected in the structure editor. Here are the possibilities and the outcomes:
- No table is selected
Result: A new table is created with the name "FieldContainer" with the same fields - The table containing the copied fields is selected
Result: The fields are pasted in the table with "Copy_of" prepended to the field names - Another table is selected
Result: The fields are pasted in the table with the same name, unless an existing field in the table has the same name as one of the pasted fields, in that case the pasted field name will be prepended with "Copy_of" - A field in any table is selected
Result: A new table is created with the name "FieldContainer" with the same fields