Maximo

Maximo

Come for answers, stay for best practices. All we're missing is you.

 View Only
  • 1.  7.6.1.2 - Calling an ACTION in automation script

    Posted Fri April 29, 2022 02:12 PM
    Hi,

    I am calling an ACTION in the automation script. Action sets the value of the DESCRIPTON for all locations to let say "New Description", Automation script runs fine but when I refresh the location screen, it doesn't show me the new descriptions.

    However, if I run the same ACTION from an escalation, it updates the location description.

    Is it possible to call an ACTION in an automation script ?

    mxServer = MXServer.getMXServer()
    userInfo = mbo.getUserInfo()
    actionSet = mxServer.getMboSet("ACTION", userInfo)
    actionSet.reset()
    actionSet.setWhere("action = 'SETDESCRIPTION'")

    if(not actionSet.isEmpty()):
    action = actionSet.getMbo(0)
    action.executeAction(mbo)

    actionSet.commit()
    actionSet.save()
    actionSet.close()

    Thank you, 
    Mohammad Hamid Naseer


    ------------------------------
    Mohammad Hamid Naseer
    ------------------------------

    #AssetandFacilitiesManagement
    #Maximo


  • 2.  RE: 7.6.1.2 - Calling an ACTION in automation script

    Posted Fri April 29, 2022 02:20 PM
    Mohammad,

    This is an interesting use case. I'd be concerned that you're trying to open/modify the current record mbo both in the Automation Script and via Action simultaneously. In my experience Maximo doesn't behave well in that type of scenario.

    If you're performing that Action against the current mbo you're probably better off incorporating the Action behavior into the script itself. Now if you're performing the Action against a related record in some way I could potentially see that working, but be careful if it's part of the current MBO structure.

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



  • 3.  RE: 7.6.1.2 - Calling an ACTION in automation script

    Posted Fri April 29, 2022 05:26 PM
    Hi Tim, 

    Thanks for your reply. No, I am not updating the current record, instead I want to update all the Location Descriptions with Action.

    The reason I am trying to do that, our customer has a custom date field lets' say RETIRE_DATE, This is populated through a process. User don't have access to SQL Developer where he can run an update statement like UPDATE LOCATIONS SET RETIRE_DATE=NULL to set all RETIRE_DATE to null. So we thought we can provide an option to user through Automation Script which will call an ACTION and it will set the RETIRE_DATE to null for all the locations in the LOCATIONS table. User can run this option from drop down menu on Location app.

    Now with this background, I tested the above DESCRIPTION example and it perfectly worked fine from ESCALLATION and it setup the DESCRIPTION to NULL for all LOCATIONS in my demo environment. However when I tried to call it from the automation script, it did nothing, so was wondering is it possible to call ACTION from an Automation Script and is it equivalent to calling it from Escalation ?  

    Thank you, 
    Mohammad Hamid Naseer
    We have requirement where we have a custom field, we want to give option to user to

    ------------------------------
    Mohammad Hamid Naseer
    ------------------------------



  • 4.  RE: 7.6.1.2 - Calling an ACTION in automation script

    Posted Fri April 29, 2022 05:34 PM
    Mohammad,

    I see. I would assume the answer would be yes, but I can't think of a single use case where this would gain you any benefit. You are going to be much better off just setting the value or changing the status directly from the Automation Script rather than trying to call an Action. Even if you were calling an Action Group things are going to be much more efficient if you just perform the steps from the Automation Script itself.

    In the example you provided this could be something as simple as mbo.setValue('RETIRE_DATE', None).

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



  • 5.  RE: 7.6.1.2 - Calling an ACTION in automation script

    Posted Fri April 29, 2022 06:30 PM
    Hi Tim, 

    Let me give you little more background to make sense of the solution that I presented in my first message. There is an automation script which populates RETIRE_DATE value based on some business logic. We have number of automation scripts running on LOCATION object on different events like save, update for different business solutions. When we were setting up the RETIRE_DATE value from the mbo.setValue("RETIRE_DATE".....) , it took us around 2 hours in client's environment to update the values for records listed in the Result Set. So we have to drop this idea and instead we created a CSV file on the server, created an enterprise service, setup a flatflieconsumer crontask instance to run this update in the background. So user session is not stuck otherwise user can't use Maximo till the time the process was running. 

    I was looking for a more decent solution to do it through ACTION, if it doesn't work then I will probably go for the following solutions which is working fine in my Demo env. 

    conKey = ""
    con = ""
    s = ""

    try:
    mxserver = MXServer.getMXServer()
    userInfo = mxserver.getSystemUserInfo()
    conKey = mbo.getThisMboSet().getUserInfo().getConnectionKey()
    con = mbo.getThisMboSet().getMboServer().getDBConnection(conKey)
    s = con.createStatement()
    val = "Update Locations Set RETIRE_DAET = NULL where RETIRE_DATE != NULL"
    #val = "Select * from Locations"
    logger.info(val)
    logger.info("Before executing")
    rs = s.execute(val)
    logger.info("after execution")
    con.commit()
    finally:
    if s != "":
    s.close()
    if conKey != "" and con != "":
    mbo.getThisMboSet().getMboServer().freeDBConnection(conKey)

    ------------------------------
    Mohammad Hamid Naseer
    ------------------------------



  • 6.  RE: 7.6.1.2 - Calling an ACTION in automation script

    Posted Fri April 29, 2022 06:39 PM
    Mohammad,

    Ok, I get the thing about not wanting to cripple the JVM running the job, but you can run a Script from an Escalation/Action, so you could force it to run on a particular node if necessary.

    Actions only perform a few specific things, and Automation Scripts can do each of these, only more powerfully. I still don't see a use case here.

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



  • 7.  RE: 7.6.1.2 - Calling an ACTION in automation script

    Posted Mon May 02, 2022 04:46 PM
    Hi,

    I agree with Tim, the script should just have the setString call and not all the Action processing.  That said, a couple of other points.  First, I think you have the reset and the setWhere in the wrong order.  So, that may in part be the problem.  In any case, I would avoid having the save and commit in the script as that can cause other issues if you are not careful.  Specifically, once the save is done then any subsequent changes will not be saved unless the record is re-fetched first.  So, depending on when this script is actually firing, it might be after a save and therefore having no effect.   How/when does the script fire?

    ------------------------------
    Steve Hauptman
    ------------------------------