Are you saying that your parent record isn't autonumbering on duplication? You can force it to generate an autokey (assuming you're using our standard functionality) for that record by doing something like this:
permitValue=dupmbo.getMboValue("X1PERMITNUM")
permitValue.autoKey()
Then assuming you're defaulting this value on the child object utilizing the add() method (either java class or OBJECTNAME.NEW automation script) it should carry down to the child if you call the copy() after generating the autokey on the new parent record.
------------------------------
Steven Shull
------------------------------
Original Message:
Sent: Wed June 29, 2022 10:35 AM
From: Teng Moua
Subject: Custom App - Duplicate Event to copy child table data
After some more testing, i'm having a hard time setting the key value on the child table. The key value X1PERMITNUM is the Maximo autogenerated number on the main record that links between the Main record and Child record. Since it's autogenerated when I do the permitNum = dupmbo.getString("X1PERMITNUM"), this value is blank.
------------------------------
Teng Moua
------------------------------
Original Message:
Sent: Wed June 22, 2022 08:20 AM
From: Steven Shull
Subject: Custom App - Duplicate Event to copy child table data
You have to utilize the CUSTOMBOJECT.DUPLICATE to duplicate your child objects. Each object in Maximo that supports duplication overrides the DUPLICATE() method to make copies of the necessary child tables. I documented a simple example of copying a child object here: https://ibm-maximo-dev.github.io/maximo-autoscript-documentation/objectscripts/duplicateobject
An important thing to be aware of is on custom objects, you sometimes need to write the logic to update the key values of how you map from the parent object to the child object. In that scenario you would need to loop through and set the values. It depends on how the custom object was written whether that would be required.
------------------------------
Steven Shull