Maximo

 View Only
  • 1.  Record change Bug while calling save in Attribute Level Automation Scripts

    Posted Thu July 28, 2022 10:42 AM

    Whenever new record is created and above Attribute level Script is triggered (i.e before manually clicking save from UI), current record gets changed to any random record. 
    The same script works fine for records that already exists in DB. What could be the possible fix for this bug.

    ------------------------------
    aditi jain
    ------------------------------

    #AssetandFacilitiesManagement
    #Maximo


  • 2.  RE: Record change Bug while calling save in Attribute Level Automation Scripts

    Posted Thu July 28, 2022 12:28 PM
    If you're doing this on an existing record you have a predefined set of records selected (on the List tab). Not necessarily so if you're creating a new record.

    I would also strongly recommend against saving the MBO Set (even a single record) on a new record from a script. You are borrowing trouble at best. Typically in this scenario you would set the value and once the user saves the record it is applied to the database at that point.

    ------------------------------
    Tim Ferrill
    Solutions Consultant
    Intelligent Technology Solutions
    tferrill@webuildits.com
    www.webuildits.com
    @tferrill/@webuildits
    ------------------------------



  • 3.  RE: Record change Bug while calling save in Attribute Level Automation Scripts

    Posted Fri July 29, 2022 09:17 AM
    I have to strongly second what Tim stated. Never save for the user based on a field being entered. It's not just the change to your field that gets saved and you prevent them from having a chance to discard it. They may not have everything defined that they need. 

    The reason this redirects you to a random record where the user explicitly saving does not is because there is logic in the AppBean save method that handles getting back to the newly created record. Since you're calling save on the set (not utilizing the app bean), you don't have this special logic to handle getting back to this record.

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



  • 4.  RE: Record change Bug while calling save in Attribute Level Automation Scripts

    Posted Fri July 29, 2022 01:22 PM
    Thank you very much Steven and Tim for your inputs.
     
    I understand that calling Save in Attribute level script is never recommended, but same redirect is happening on Action level script too (while button click on new records). 
    So if I really have a case where I need to save a new record from button, then should incorporating missing logic that " handles getting back to the newly created record"
    work?



    ------------------------------
    aditi jain
    ------------------------------



  • 5.  RE: Record change Bug while calling save in Attribute Level Automation Scripts

    Posted Fri July 29, 2022 01:35 PM
    You have to interact with the bean class so you might as well just call the bean class save event. For an action button, you have access to the UI framework pretty easily. Something like below

    session=service.webclientsession()
    appBean=session.getCurrentApp().getAppBean()
    appBean.save()

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



  • 6.  RE: Record change Bug while calling save in Attribute Level Automation Scripts

    Posted Fri July 29, 2022 02:30 PM

    Hi Steven, I tried your code and it worked great !!
    Thank you so much for helping out.

    from psdi.common.context import UIContext
    from psdi.webclient.system.controller import SessionContext, Utility, WebClientEvent
    from psdi.webclient.system.session import WebClientSessionManager
    from psdi.mbo import MboConstants
    
    mbo.setValue("ATTR1", "12")
    
    session=service.webclientsession()
    appBean=session.getCurrentApp().getAppBean()
    appBean.save()


    ------------------------------
    aditi jain
    ------------------------------