Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.
Record Cloning is used to replicate or duplicate a certain record. All the data within a record is replicated into a new record with a new record number. Using this feature, you can create similar records multiple times with minimal data changed in certain fields. This way, the rest of the data remains intact and only the fields that need to be updated are changed in the new record.
You can use this feature generally or specifically.
Record Cloning is done using a piece of Java code. This Java code provides the functionality using AgileApps macros.
Use the MACROS feature of AgileApps which allows you to create a dropdown feature in the record view section.
You can use the below general code for record cloning:
package com.platform.softwareag_agileapps.test; import com.platform.api.*; import com.platform.api.Logger; import java.util.*; import com.platform.beans.*; import com.platform.api.Result; import com.platform.api.Parameters; public class recordClone { //This section is used for Initializing Variables public void cloneRecord(Parameters p) throws Exception { String recordId = p.get("id"); // Gets Record_ID (id) for the Object String record_ObjectId = p.get("object_id"); // Gets object_id for Object Logger.debug(recordId, "recordClone"); Logger.trace(record_ObjectId,"recordClone"); try { //Get the object name based on the object id. CustomObjectMetaDataBean mdb = Functions.getObjectMetaData(record_ObjectId); Logger.info("The objject id at getting object name"+record_ObjectId, "recordClone"); String objectName=mdb.getObjectName(); Logger.trace("The object name is " +objectName, "recordClone"); //Adding the current record, as Parameters object "p" contains all the record data. Behaves similar to this object. Result addRecordResult = Functions.addRecord(objectName,p); int recordCode = addRecordResult.getCode(); if(recordCode<0) { String msg = "Record cannot be cloned"; Logger.info(msg + ":\n" + addRecordResult.getMessage(), objectName); // Log details Functions.throwError(msg + "."); // Error message } Logger.trace("the keys are "+p, "recordClone"); } catch (Exception e) { String msg = e.getMessage() + "\n methodName(): "+e.getClass().getName(); Functions.throwError(msg); } } }
Hi Ron,
This code will have to be extended further to handle related items as well.
Thanks Gaurav
Can this code be modified to allow the cloning of the related items as well? For instance a purchase order has multiple PO_Items which need to be cloned as well.