Maximo Open Forum

 View Only

Using a script to create a new child record via a log box

  • 1.  Using a script to create a new child record via a log box

    Posted 11-03-2021 11:33
    Generalized background--I have a Maximo application definition that contains a defined data source src_child and a defined dialog box dialog_child that has its datasource="src_child"

    There is a defined action-based automation script CRTCHILD that is authorized for use w/in the application, and associated with a push button on the mainrecord.  

    The PROBLEMS I'm having are two-fold:
    1. How to most elegantly get a newly created child mbo via the script so that I can set values AND have it show up properly in the dialog box
    2. How to get the dialog box to properly display the newly created child mbo found in #1

    This is the script I've been using--it WORKS (accomplishes both #1 and #2), but it is ugly.  Curious if anyone has suggestions about how to improve!

    from psdi.server import MXServer;
    from psdi.mbo import MboConstants;
    
    ## Get context
    session = service.webclientsession();
    databean = session.getDataBean("src_child");
    set = databean.getMboSet();
    
    ## Add the row
    databean.addrow();
    
    ## This is what I have to do to accomplish #1 ##
    set = databean.getMboSet();
    ID = 0;
    s = set.moveFirst();
    while (s != None):
        if (s.getLong("PLUSGSHFTLOGENTRYID") > ID):
            ID = s.getLong("PLUSGSHFTLOGENTRYID");
        s = set.moveNext();
        
    child = databean.getMboForUniqueId(ID);
    # child = set.moveLast(); ## this doesn't reliably work
    owner = child.getOwner();
    
    ## Set values
    child.setValue("FIELDS HERE", "VALUES HERE", FLAGS_HERE);
    
    ## Load the row
    session.loadDialog("dialog_child");
    
    ## This is what I have to do to accomplish #2 ##
    service.error("GRE", "NONE", [""]); ## this halts things such that the dialog box opens on the right mbo

    #EverythingMaximo

    ------------------------------
    Jade Warren
    Great River Energy
    ------------------------------