OBJECTNAME.DUPLICATE Script
This is a special type of automation script without a launch point. The name of the script must be in the format OBJECTNAME.DUPLICATE or OBJECTNAME.AFTERDUPLICATE. For example, if you wanted a script on PO you would call it PO.DUPLICATE.
These two events allow you to control logic that occurs when duplicating records. There are a variety of scenarios where this might be useful. The following examples are some scenarios where it may be useful:
- Could be utilized to clear out values during duplication that cannot be be flagged to skip
- Could be utilized to maintain a reference between the two records
- Could be utilized to copy additional child objects that might not be handled by default, for example, custom objects
The difference between .DUPLICATE & .AFTERDUPLICATE is when the code is triggered.
DUPLICATE occurs in the MBO method for copying the record. That means any time duplicate() or copy() are called on the MBO, including inside an automation script or integration, the .DUPLICATE script will be triggered. This is going to occur prior to any child data sets (for example, DOCLINKS, POLINES) being copied. If you need to modify those child data sets after they are copied you would need to create a script on the child data set named IE POLINE.DUPLICATE, or utilize AFTERDUPLICATE.
AFTERDUPLICATE is currently handled in the DataBean class, from which the the classic Maximo UI extends, and the REST API action for duplicating a record. That means other events that would cause a record to duplicate, such as calling mbo.duplicate() inside of an automation script will NOT cause this script to execute. This limitation is important to understand to determine if this event can be utilized. AFTERDUPLICATE will occur after all the logic for duplication has occurred. For example, if the duplicate() function of a MBO copies in child data sets, those child data sets will have been copied when AFTERDUPLICATE executes.
Implicit variables
Variable name | Description |
---|---|
mbo | The original MBO record that was duplicated |
dupmbo | The newly created MBO record |
Example Script
# Clear out existing valuesdupmbo.setValueNull("ASSETNUM")# Copy custom object set into new record# NOTE: You most likely would need to update the values that point to your record, such as WONUM, to the new record.origChildSet=mbo.getMboSet("MYCUSTOMRELATIONSHIP")origChildSet.copy(dupmbo.getMboSet("MYCUSTOMRELATIONSHIP"))