Maximo Open Forum

 View Only

 Automation Script add new row on child table from button

Jump to  Best Answer
  • Maximo Application Suite
Eric Burkland's profile image
Eric Burkland posted 06-04-2025 19:38

Good Evening all,

I have custom buttons which add Labor Records on Work orders and default values.  I accomplished this with a traditional Java customization in the past.  Now these customizations are not working properly after I apply the May 2025 update for MAS/Manage 9.0.

Does anyone have a complete example of how to add an automation script to a button on a child record?  I cannot get it to execute for the life of me.

UPDATE:  
Here's how I solved my issue by following the link Alex provided https://www.linkedin.com/pulse/ibm-mas-manage-ui-bean-scripting-andrzej-wieclaw-4vtbf/
Thanks to others for the suggestions, I'm sure there are multiple ways of doing this.

  1. Set System Property mxe.script.allowbeanscript = 1
  2. Create an automation script named DATABEAN.<custom-name>  Ex: DATABEAN.WOTRACK.ACTUALS.LABOR
    1. Be sure to check the "Allow Invoking Script Functions?" checkbox
    2. For DataBeans you have to add variables to the script with Variable Type "IN" and Binding Type LITERAL
      1. beanid = actuals_actuals_aclabor_aclabor_table    You find this in the application XML. IN my case this was the id of the <table>
      2. beanapp = WOTRACK
    3.  The function inside your script has to have the same as the the mxevent.  In my case mxevent="addrowWithLabor"

from psdi.server import MXServer

def addrowWithLabor(ctx):
    mxserver = MXServer.getMXServer()
    control = ctx.getEvent().getSourceControlInstance()
    databean = control.getDataBean()

    rowadd = databean.addrow()
    ltmbo = databean.getMbo()
    currentuser = ltmbo.getUserInfo()
    personid = currentuser.getPersonId()
    try:
        personset = mxserver.getMboSet("PERSON", currentuser)
        personset.setWhere("personid = '" + personid + "'")
        personset.reset()
        if not personset.isEmpty() and not personset.getMbo(0).isNull("locationorg"):
            laborset = mxserver.getMboSet("LABOR",currentuser)
            laborset.setWhere("orgid = '" + personset.getMbo(0).getString("locationorg") + "' and personid = '" + personid + "'")
            laborset.reset()
            if not laborset.isEmpty() and not laborset.getMbo(0).isNull("laborcode"):
                ltmbo.setValue("LABORCODE",laborset.getMbo(0).getString("laborcode"))
                
    finally:
        laborset.cleanup()
        laborset.close()
        personset.cleanup()
        personset.close()

Alex Walter's profile image
Alex Walter  Best Answer

A good summary of UI Scripting and its capabilities is found here:

https://www.linkedin.com/pulse/ibm-mas-manage-ui-bean-scripting-andrzej-wieclaw-4vtbf/

Hope this helps,

Alex

Niv Geo's profile image
Niv Geo

Hi Eric

Situations and Scenarios can vary but could you pass a screen shot or sample code of what you are trying to achieve.

Eric Burkland's profile image
Eric Burkland

@Alex Walter Hope you are doing well and thank you for the information!  This is very interesting.  I actually figured out that on a child record I could get the code to execute but only when there were 1 or more rows in the table.  If there were zero rows it would not execute.  This suggests to me what your article describes which is there are limitations on the traditional automation scripting classes and events.  I'll have to explore some of these new avenues.  

Thanks again,
Eric

Jade Warren's profile image
Jade Warren

I have solved this problem by opening the application XML in an editor and then putting a SECTION control below the table details.  You can then set the data source ID of the SECTION = mainrecord and place your action button (to add the row + set values) w/in that section.  Then, the button push will work 100% of the time, even if there are not yet any child rows in the table.