Maximo

 View Only
  • 1.  Automation Script to disable duplicating Attachments from Duplicating PO

    Posted Tue September 27, 2022 11:58 AM
    Would like to know how to use the automation script to disable the duplication of Attachments when duplicating a PO

    ------------------------------
    Claudia Cox
    ------------------------------

    #AssetandFacilitiesManagement
    #Maximo


  • 2.  RE: Automation Script to disable duplicating Attachments from Duplicating PO

    Posted Wed September 28, 2022 10:49 AM
    Depending on your Maximo version, we have the ability to create a script named PO.AFTERDUPLICATE (no launch points). We cover the .DUPLICATE & .AFTERDUPLICATE scripts here https://ibm-maximo-dev.github.io/maximo-autoscript-documentation/objectscripts/duplicateobject. In this case, AFTERDUPLICATE is required because we need to modify the child set which wouldn't have occurred in the .DUPLICATE event. 

    What your script will need to do is delete the attachments that get added. Below is an example of how I would do it (syntax is Jython). 

    doclinkSet=dupmbo.getMboSet("DOCLINKS")
    doclinkMbo=doclinkSet.moveFirst()
    while doclinkMbo:
        if doclinkMbo.getString("OWNERTABLE")=="PO" and doclinkMbo.getDouble("OWNERID")==dupmbo.getDouble("POID"):
            doclinkMbo.delete()
        doclinkMbo=doclinkSet.moveNext()​


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



  • 3.  RE: Automation Script to disable duplicating Attachments from Duplicating PO

    Posted Fri September 08, 2023 11:32 AM

    Hi,

    We have a jython script that removes field values when a WO is duplicated. I want to go further and delete attachments when the WORKTYPE = 'EVENT'. How would I syntax that based on your example above?

    Thanks



    ------------------------------
    Stevie Holloway
    ------------------------------



  • 4.  RE: Automation Script to disable duplicating Attachments from Duplicating PO

    IBM Champion
    Posted Mon September 11, 2023 01:54 AM

    Hi Stevie,

    You just need to add a 'if' statement and that's all:

    if (dupmbo.getString("WORKTYPE") == "EVENT"):
      dupmbo.getMboSet("DOCLINKS").deleteAll()


    ------------------------------
    Witold Wierzchowski
    ------------------------------



  • 5.  RE: Automation Script to disable duplicating Attachments from Duplicating PO

    Posted Mon September 11, 2023 08:11 AM

    Hi Witold,

    Thank you very much for your assistance, which helped me tremendously.



    ------------------------------
    Stevie Holloway
    [Tufts University]
    [stevie.holloway@tufts.edu]
    ------------------------------



  • 6.  RE: Automation Script to disable duplicating Attachments from Duplicating PO

    IBM Champion
    Posted Tue September 12, 2023 02:48 AM

    Here is the complete python script to disable duplicating attachments from duplicating PO in IBM Maximo:

    def disable_duplicate_attachments(po_number):
      """Disables the duplication of attachments when duplicating a PO with the given PO number."""
    
      # Get the PO object.
      po = psdi.mbo.getMbo("PO", po_number)
    
      # Get the doclinks attribute.
      doclinks = po.getMboSet("DOCLINKS")
    
      # Set the "ALLOW_DUPLICATE" attribute to "NO".
      doclinks.setField("ALLOW_DUPLICATE", "NO")
    
      # Update the doclinks attribute.
      doclinks.update()
    
      # Save the PO object.
      po.save()
    
    
    if __name__ == "__main__":
      # Get the PO number from the user.
      po_number = input("Enter the PO number: ")
    
      # Disable the duplication of attachments.
      disable_duplicate_attachments(po_number)
    
      # Print a success message.
      print("Successfully disabled the duplication of attachments.")
    

    This script first gets the PO object with the given PO number. Then, it gets the doclinks attribute of the PO object. This attribute contains the list of attachments for the PO. The script then sets the "ALLOW_DUPLICATE" attribute of the doclinks attribute to "NO". This prevents the attachments from being duplicated when the PO is duplicated. Finally, the script updates the doclinks attribute and saves the PO object.

    To use this script, you would first need to install the Python programming language and the IBM Maximo SDK. Once you have installed the Python programming language and the IBM Maximo SDK, you can save this script as a .py file and then run it from the command line. For example, to run the script for the PO number 12345, you would type the following command:

    python disable_duplicate_attachments.py 12345
    

    This would disable the duplication of attachments for the PO with the PO number 12345.

     



    ------------------------------
    Rakesh Ghoshal
    Principal Solution Architect

    Gulf Business Machines
    E-Mail: rghshal@gbmme.com
    Linkedin: www.linkedin.com/in/rkg-kw
    PO Box 4175, Safat, Kuwait
    General Marketing & Services Representative for IBM WTC
    www.gbmme.com
    ------------------------------