rbv_api.getcloneRecord()

Warning: Support for using this method with external objects (such as those mapped to external tables, to OpenEdge Service objects, or through a HDP connection) is a beta feature. This method is supported in production systems, except for external objects.

Purpose

This Object Script method clones an existing object record and applies the unique values to the new record. The Object Script API invokes triggers on create, on update, and on delete the same way as the Platform user interface does. The ID of a newly created record is available for other triggers in the update chain through the shared value, newID_objectName, that can be retrieved using getSharedValue().

Note: This method observes required and unique field properties. An attempt to create or update a record without setting required fields or by violating the uniqueness of field values will cause an error.

Formulas used in Object Script triggers can include other API methods and regular Platform template functionality, such as loops. Object Script methods have no effect if called outside of update triggers.

Syntax

rbv_api.getcloneRecord(objName, ID, arr, cloningConfig)		

Parameters

objName

The Integration name of the type of object to create.

id

An ID of the record to clone.

arr

(Optional Parameter) JavaScript array of field name/value pairs (unique fields must be supplied)

Use these field name/value pairs to override values from the source record (ID). Ensure that new values are provided for fields that are unique; otherwise, the cloning process may fail due to duplicate value errors.

cloningConfig

(Optional Parameter) JavaScript array representing the values shown in the cloning modal. These values are applied to generate new entries for unique fields when cloning records from related object definitions, including those with hierarchical relationships.

 

Return value

The Object ID of the newly created record.

Permissions Required

Create permission for the selected object type and View permission on the record to be cloned.

Example

  1. When arr is null, cloningConfig is not null

    var findReplace = {
    "cloned1": "cloned2",
    "rec-name": "rec-name2"
    };
    const clone = {"prefix":"nbnbnbn","findReplace": findReplace};
    var newId = rbv_api.cloneRecord("cloned", !{id}, null, clone);
  2. When arr is not null, cloningConfig is not passed.

    var x = new Array();
    x["name"]= "updatedName";
    x["text_unique"] = "unique";
    var newId = rbv_api.cloneRecord("cloned", !{id}, x);
  3. When both arr and cloningConfig are passed.

    var findReplace = {
    "cloned1": "cloned2",
    "rec-name": "rec-name2"
    };
    var x = new Array();
    x["name"]= "updatedName";
    x["text_unique"] = "unique";
    const clone = {"prefix":"nbnbnbn","findReplace": findReplace};
    var newId = rbv_api.cloneRecord("cloned", !{id}, x, clone);