Copy Business Object

After a business object is added and its values defined, you can copy or clone the object with the Copy Businessobject command.

This page discusses:

Syntax

This command lets you duplicate a business object’s defining clauses and change some of the values at the same time.

While grants are not a defining clause, when business objects are copied, any and all grants are also copied to the new object. You cannot revoke the accesses within the copy businessobject command.

You might first view the object’s contents using the Print Businessobject commands described in Print Business Object. Then you can use the Copy Businessobject clauses listed below to modify the values you want to change. You should recognize these clauses since they are the same in the Add Businessobject command.

copy businessobject OBJECTID [!file] to NAME REVISION [history] 
[MOD_ITEM {MOD_ITEM}] [SELECT [DUMP] [RECORDSEP] [tcl] [output FILENAME]];

  • OBJECTID is the OID or Type Name Revision of the existing business object.
  • NAME is the name for the new business object. If you use the same type, name and revision as the original business object, an error will occur and the business object will not be copied.
  • REVISION is the revision label or designator. If a revision is desired, it should be specified as the full revision string (major-minor) as specified in the governing policy (see MQL Concepts: About Major and Minor Revisions). Otherwise, it is "" (a set of double quotes).
  • MOD_ITEMs are modifications that you can make to the new definition. For more information, see Modify Business Object.

Any of these values can be changed as you copy the business object. You only need to include clauses for the values that you want to change. If you do not make any changes, the values remain the same as the original business object with the new name you have assigned.

Handling Files

If you want to clone an object without including the original files in the new object, use the following syntax:

copy bus OBJECTID [!file] to NEWNAME REVISION [Vault];

The placement of the !file clause must follow the above exactly or an error will occur.

Since files are included by default, include the !file clause and they won’t be copied. For example:

copy businessobject “Shipping Form” “Lyon’s Order” 5 !file to “Ryan’s Order” 1;

Including History

By default, when a new object is created with the copy command (or using the Studio Customization Toolkit or GUI), the only history record it has is similar to:

history = create - user: creator time: Mon Sep 12, 2005 10:28:58 PM EDT  state: one  revisioned from: T1 1 0

To include the history of the original object in MQL, use:

copy businessobject BO_NAME to NAME REVISION history;

After copying the history records from the original object to the cloned object, the additional create history record will be appended indicating that it is a copy (revisioned from), as shown above.

Since the command is intended for use within a program object, it is up to the calling program to handle any errors.