Maximo

Maximo

Come for answers, stay for best practices. All we're missing is you.

 View Only
  • 1.  Copy Doclinks

    Posted Mon April 20, 2026 10:45 AM

    We have a custom application that we can attach doclinks to. We would like to copy all the attachments when we duplicate the record. It doesn't do that "out of the box" so we tried an automation script using the "afterduplicate" automation script. However, we are getting multiples when ran.

    from psdi.mbo import MboConstants
    
    orig_doclinks_set = mbo.getMboSet("DOCLINKS")
    
    dup_doclinks_set = dupmbo.getMboSet("DOCLINKS")
    
    orig_doclink = orig_doclinks_set.moveFirst()
    while orig_doclink:
        new_doclink = dup_doclinks_set.add()
        
        new_doclink.setValue("DOCTYPE", orig_doclink.getString("DOCTYPE"), MboConstants.NOACCESSCHECK)
        new_doclink.setValue("DESCRIPTION", orig_doclink.getString("DESCRIPTION"), MboConstants.NOACCESSCHECK)
        new_doclink.setValue("URLTYPE", orig_doclink.getString("URLTYPE"), MboConstants.NOACCESSCHECK)
        new_doclink.setValue("URLNAME", orig_doclink.getString("URLNAME"), MboConstants.NOACCESSCHECK)
        new_doclink.setValue("ADDINFO", orig_doclink.getBoolean("ADDINFO"), MboConstants.NOACCESSCHECK)
    
        orig_doclink = orig_doclinks_set.moveNext()

    Here is the result. There should only be the second entry, not sure why we are getting the first, there is only a single attachment in the original record.

    Even stranger, deleting the first attachment, deletes them both.

    Does anything look incorrect with the script? Or maybe a setting that does the copy when duplicated that I missed?



    ------------------------------
    Jason Johnson
    ------------------------------


  • 2.  RE: Copy Doclinks

    Posted Tue April 21, 2026 08:56 AM

    Attachment from originating WO is shown on duplicate out of the box. 



    ------------------------------
    Juris Flugins
    Expert IT Consultant
    TROIA d.o.o
    Jurmala
    ------------------------------



  • 3.  RE: Copy Doclinks

    Posted Tue April 21, 2026 07:44 PM

    Hi Jason,

    Doclinks has 2 parts: DOCINFO and DOCLINKS table.

    Get another mboSet with the DOCINFO relationship, and in your loop, add a new docinfo and copy the data, replacing the ownerid and ownertable with your custom object. Then you can create the doclinks as you already are, but update the docinfo fields in the doclink MBO with the docinfo you just created.

    Try that and see how it goes. I would also suggest using the Maximo Development Tools (https://marketplace.visualstudio.com/items?itemName=sharptree.maximo-script-deploy), which now supports live debug.



    ------------------------------
    If this post helps, please consider accepting it as a solution to help other members find it more quickly.

    Maycon Belfort
    Cloud and Infrastructure Engineer
    Naviam
    Melbourne
    ------------------------------