Maximo Open Forum

 View Only
  • 1.  Record should not be saved if Attachment is not Attached

    Posted 11-24-2021 02:47

    Hi everyone,

    I am working on Maximo Attachments but am facing an issue. Please provide your valuable guidance to resolve this issue.

    Requirement : In the Maximo PR application, the new PR record should be saved only if at least one attachment is attached, else the record should not be saved and through the error.

    Implementation : For this, I have created an automation script on PR Object Launch point before the Save method and the Error message in Database Configuration.

    Issue : The script is triggering when I am trying to attach the attachment and through an error message that I have written.

    Note : I have changed the Launch point before Save method to the After Save method but still have the same issue, I thought the script would be triggered before saving the PR record, but when I am trying to attach the attachment itself, the PR record is trying to save and the script is triggering and thronging the same error.

    It would be greatly helpful if you could correct my mistake and also provide any other alternative way to achieve this requirement.

    Let me know if any further information is needed.

    Thanks :)

    The below script is working as expected, but it is not running as expected.


    #Administration
    #Analytics
    #Architecture
    #Assets
    #CivilInfrastructure
    #Customizations
    #EndUser
    #EverythingMaximo
    #HSE/OilandGas
    #Infrastructure
    #Integrations
    #Inventory
    #IoT
    #LifeScience/Calibration
    #Linear
    #MaximoApplicationSuite
    #MaximoForAviation
    #MaximoUserGroups
    #Mobility
    #Nuclear
    #Procurement
    #Reporting
    #Scheduling
    #Security
    #ServiceProvider
    #Spatial
    #Transportation
    #Utilities
    #WorkCenters
    #WorkManagement

    ------------------------------
    Venkatrao Y
    TCS
    ------------------------------


  • 2.  RE: Record should not be saved if Attachment is not Attached

    Posted 11-24-2021 16:17
    The standard Maximo can't let you attach a file before the save, that's why the save is invoked every time when you want to attach a file.

    I suggest here to implement your validation after the first save to rich your requirement.

    I have also a comment about your script , you don't need to work the the temporary relationship between po and attachement. You haev just to go directly with the relationship DOCLINKS (ownerid=:poid and ownertable='PO').

    I think the final version of your script should be like the following:

    if(not mbo.toBeAdded()):
      doclinksSet=mbo.getMboSet("DOCLINKS");
      if(doclinksSet.isEmpty()):
          errorgroup="docgroup";
          errorkey="dockey";
       

    I hope this will help you.

    ------------------------------
    Riadh Sbita
    Smartech
    ------------------------------



  • 3.  RE: Record should not be saved if Attachment is not Attached

    Posted 12-02-2021 09:39
    You can't handle this with just a script. You have to change how attachments are added. Look at how this is done in the CREATESR application with their table control and bean classes and implement that in your PR application. Your users will be able to utilize that to add attachments prior to the record being saved and then your checks will work.

    You'll then have a separate issue. The way your code is written won't work because the data won't exist in the database and you're establishing a new set (not using what exists in memory) so it would have to query the database. Assuming it would have worked, I would use notExist() over count(). notExist queries the dummy_table for a record existing in your table with that criteria and can save time on larger tables since the database just needs to find 1 record instead of all records that match the criteria.  I also couldn't follow the script being on PR save and going back to the set to get the PR mbo? Not sure why you wouldn't always use mbo as that is the PR in process of being saved. 

    I would write this (end to end, you don't need any of your imports) like this:
    doclinkSet=mbo.getMboSet("DOCLINKS")
    doclinkMbo=doclinkSet.moveFirst()
    recordFound=False
    while doclinkMbo and not recordFound:
        if doclinkMbo.getString("OWNERTABLE")=="PR" and doclinkMbo.getDouble("OWNERID")==mbo.getDouble("PRID"):
    	recordFound=True
        doclinkMbo=doclinkSet.moveNext()
    
    if not recordFound:
        service.error("docgroup","dockey")​


    ------------------------------
    Steven Shull
    IBM
    ------------------------------