Maximo

 View Only
  • 1.  Custom App - Duplicate Event to copy child table data

    Posted Tue June 21, 2022 10:09 AM
    We created a custom app using custom objects.  When using the Duplicate even to duplicate a record, only the Main object data is duplicated.  Is there a way to also copy the child table data?  The customobject.duplicate automation script seems to only be for the Main Record object.

    ------------------------------
    Teng Moua
    ------------------------------

    #AssetandFacilitiesManagement
    #Maximo


  • 2.  RE: Custom App - Duplicate Event to copy child table data

    Posted Wed June 22, 2022 08:20 AM
    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
    ------------------------------



  • 3.  RE: Custom App - Duplicate Event to copy child table data

    Posted Wed June 22, 2022 02:34 PM
    Thanks for the example.  I was able to add that to our duplicate script and copy the child data over.​

    ------------------------------
    Teng Moua
    ------------------------------



  • 4.  RE: Custom App - Duplicate Event to copy child table data

    Posted Wed June 29, 2022 10:35 AM
    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
    ------------------------------



  • 5.  RE: Custom App - Duplicate Event to copy child table data

    Posted Thu June 30, 2022 08:54 PM
    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
    ------------------------------



  • 6.  RE: Custom App - Duplicate Event to copy child table data

    Posted Tue November 15, 2022 09:32 AM
    Hi Teng,

    Hope you are doing well.
    Im also doing exactly the same. i.e  duplicate script to copy the child data over.
    Could you please help me with this? Thanks


    ------------------------------
    channakshava gode
    ------------------------------



  • 7.  RE: Custom App - Duplicate Event to copy child table data

    Posted Tue July 05, 2022 09:02 AM
    What if we have ASSET object and child object is custom object? There probably this would be a problem because we dont want to affect to standard solution in ASSET application Duplicate ASSET.

    ------------------------------
    Blaz Rakar
    ------------------------------



  • 8.  RE: Custom App - Duplicate Event to copy child table data

    Posted Tue July 05, 2022 09:21 AM
    There's no issue utilizing this on out of the box objects including ASSET. You wouldn't want to prevent anything that normally occurs out of the box but incorporating your own duplication of custom objects is fine.

    ------------------------------
    Steven Shull
    ------------------------------