Maximo Open Forum

 View Only
Expand all | Collapse all

MSUG - Automation Scripts in Maximo Application Suite

  • 1.  MSUG - Automation Scripts in Maximo Application Suite

    Posted 11-14-2023 07:23

    Following the successful completion of the Maximo Solutions User Group (MSUG) event, we are pleased to announce that recordings from each session will be made available to the community for extended engagement and discourse. We invite members to submit any further inquiries they may have for the speakers in the space provided below.

    Session:  Automation Scripts in Maximo Application Suite

    Presented by: @Steven Shull, IBM

    Access the Recording: https://register.gotowebinar.com/recording/9000796134191766017

    Summary: Steven discusses automation scripts, focusing on new functionality and features added to the Automation Script framework in recent years. He mentions the importance of serviceability and the potential issues that can arise from mistakes in script development. He highlights new system properties that can help handle these issues, such as automatically closing sets and deactivating all automation scripts for troubleshooting. Steven also discusses additional sources for attachments, the ability to interact with bean classes, testing automation scripts, and the warning framework that helps identify problems in scripts. He provides examples and mentions useful resources for further information.

    #MaximoApplicationSuite #automationscripts


    #MaximoUserGroups
    #MORECommunityWebinar


    #MaximoUserGroups
    #MORECommunityWebinar

    ------------------------------
    MORE Community Manager
    MORE Maximo
    ------------------------------


  • 2.  RE: MSUG - Automation Scripts in Maximo Application Suite

    Posted 11-14-2023 11:24

    There were a couple of questions I didn't get to answer on the call so I wanted to try and respond to them below.

    1) Question: Can we also import a pdf file as it is to attachments without converting the file to byte data?
    Answer: I believe this question is whether the REST API supports uploading a file without needing to convert it into base64. You can post an attachment in its native form (such as pdf) without doing a base64 conversion but it requires making a unique request per file. If you want to set data attributes on the record or upload multiple files simultaneously, then you need to use the documentdata feature which requires converting the file contents into base64. Our documentation on REST API and attachments and both examples can be found here: https://ibm-maximo-dev.github.io/maximo-restapi-documentation/attachment/attachment

    2) Question: Is there a place we can go to review these details? & Can you provide the URL for the wiki?
    Answer: Our wiki https://ibm-maximo-dev.github.io/maximo-autoscript-documentation/ is where we want to keep all this content. Some of this content hasn't been published to the wiki yet but I plan to add it. 

    3) Question: What about how to create logs for REST API?
    Answer: I don't know the entire context of what you're looking to track. We added the capability to track REST API requests in message tracking and document how to enable it here: https://www.ibm.com/support/pages/message-tracking-synchronous-requests. If there is more to the request of something specific you want to track that we don't let me know. Generically across the REST API, it would be difficult to add your own logging. But if you're trying to add additional logging to a specific object structure or REST API action we can talk about how to do that.

    4) Question: Does APPBEAN.APPNAME work for data bean as well or only App Bean?
    Answer: The script name for the appbean events will follow this format. However, if you are trying to intercept an event on a different data bean, your script name will be DATABEAN.SOMEUNIQUENAME. Then you need to define two script variables for beanid & beanapp. beanapp will be the uppercase value of the app (such as ASSET) and the beanid will be the ID where the datasource is referenced. Example:


    Trying to control the fetch of MBOs could look like below. 

    def initialize(ctx):
        mboset=ctx.getMboSetRemote()
        mboset.setQbe("metername","FIRE")

    Question 5: (I rephrased this to make the question clearer). How do you configure the automation script attachment functionality?
    Answer: We have documentation on it here: Creating scripts to manage attachments

    Ibm remove preview
    Creating scripts to manage attachments
    Maximo Manage can read or write attachments from any store that is registered with Maximo Application Suite.
    View this on Ibm >





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



  • 3.  RE: MSUG - Automation Scripts in Maximo Application Suite

    Posted 05-16-2024 17:55

    Hi Steven,

    Thank you for the presentation.

    A few questions from me:

    1) I noticed mxe.script.autocleanup is available from the System Properties in 7.6.1.3 environments. Is the functionality behind this sysprop actually there or do we have to upgrade to MAS in order to use it?

    2) What does it exactly do? Does it call the cleanup() function for any MboSets created through MXServer when the script finishes? Will that also clear the db connection linked to the MboSet?

    3) Is there a difference between clear() and cleanup()?



    ------------------------------
    Daniel Henrique
    Cohesive
    ------------------------------



  • 4.  RE: MSUG - Automation Scripts in Maximo Application Suite

    Posted 05-17-2024 15:02

    1) mxe.script.autocleanup is there in 7.6.1.3 and is functional (does not require MAS)
    2) For sets opened without an owner (IE using service.getMboSet("WORKORDER") or MXServer.getMXServer().getMboSet("WORKORDER",userInfo)) in the automation script, this builds a list of the sets and after script execution we try to close them. It's more for debugging purposes rather than intended as an actual solution. You want to look for the warnings in the log if this is recorded because you should be finding and fixing the script. 
    3) Yes, you want to use cleanup(). Clear is invoked as part of the reset that called by cleanup and there are things in cleanup that would not get invoked by clear(). 



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



  • 5.  RE: MSUG - Automation Scripts in Maximo Application Suite

    Posted 11-17-2023 06:20

    Hi Steven,

    many thanks for your presentation, there were some really interesting topics in it.

    I have one question regarding the AppBean-Scripts i forgot to ask: If i have a script for e.g. ASSET APPBEAN.ASSET, can i only use/"overwrite" the existing functions like initialize or can we also create custom functions, like ... "cxAndreasWantsToDoAddACustomActionToUI"?

    Regards,

    Andreas



    ------------------------------
    Andreas Brieke
    SVA System Vertrieb Alexander GmbH
    ------------------------------



  • 6.  RE: MSUG - Automation Scripts in Maximo Application Suite

    Posted 11-20-2023 14:50

    These hooks are for the existing bean class events where you couldn't tie an automation script before. There's no need for this to add a new event. You can create an ACTION launch point automation script and interact with the dialog, call bean methods, etc. This is a poor example but this is an action launch point automation script example of how to get the databean from a dialog, determine the records selected in that dialog, copy them over to a field (in a real-world example, this should add to a one to many object), and then close the dialog. 

    session=service.webclientsession()
    databean=session.getDataBean("emxselassets_table")
    if databean: 
        assetSet=databean.getMboSet()

        assetList=[]
        selectedRecords=assetSet.getSelection()
        if selectedRecords:
            iterator=selectedRecords.iterator()
            while iterator.hasNext():
                assetMbo=iterator.next()
                assetList.append(assetMbo.getString("ASSETNUM"))
            
            mbo.setValue("EMXSELECTEDASSETS",",".join(assetList),mbo.NOACCESSCHECK)
        service.closeDialog()



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



  • 7.  RE: MSUG - Automation Scripts in Maximo Application Suite

    Posted 11-21-2023 03:57

    Hi Steven, 

    Sad, but not the worlds end :) I know that i can gain access to UI via service.webclientsession(), but i still need a mbo for it. I had a usecase in mind where i added an action to the list of an application, but this can't fire if no mbo is shown. Some of our users were confused when clicking on that button just did nothing and gave no answer. (This was an "Approve all SR" in VIEWAPPRSR)



    ------------------------------
    Andreas Brieke
    SVA System Vertrieb Alexander GmbH
    ------------------------------



  • 8.  RE: MSUG - Automation Scripts in Maximo Application Suite

    Posted 12-28-2023 06:05

    I am too have the same requirements. :)

    Thanks,

    Amir



    ------------------------------
    Amir Nadi
    CCC
    ------------------------------



  • 9.  RE: MSUG - Automation Scripts in Maximo Application Suite

    Posted 12-28-2023 09:21

    I tested it today and in fact, it is actually possible to add brand new events and fire even if there are no MBOs on the list tab. 

    Steps to recreate:

    1) Create a new signature option (CUSTOMEVENT in my example) in the asset application. Do not change any of the advanced options like you would for a normal action based automation script. 

    2) Add the option created above to the Select Action menu. 

    3) Grant the newly created permission to your security group(s).

    4) In the APPBEAN script (IE APPBEAN.ASSET in my example), define a method with the exact same name as your signature option.

    def CUSTOMEVENT(ctx):
        ctx.launchDialog("list_status")
        ctx.setEventHandled()

    This was a very basic example but confirmed it functions even if there are no records on the list tab. 



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



  • 10.  RE: MSUG - Automation Scripts in Maximo Application Suite

    Posted 12-31-2023 02:36

    Hi Steven,

    Thanks for confirming this out.

    I have a scenario that can't get it to work. 

    I have custom dialog built on top of custom none-persistent MBO using (mboname="MyCustomObj" ) . I have added an sigoption/action to PR application ( list tab)  to open the dialog, note that the result table could have no MBOs at this stage. Now , I would like to execute a script to discard the dialog and do some business logic. 

    With the Action type automation script , this does not work so I was hoping for the bean/appbean script it could solve the issue, however, when assigning a custom event to the dialog button, it does not trigger the function in the bean script. the bean script is correctly configured as I am able to output some logs while initiating the dialog.

    The dialog looks like below

    <dialog id="CUSTOMDIALOG" label="Insert Into New Site" mboname="ZZ_CUSTOMOBJ">
    <section id="CUSTOMDIALOG_SECTION">
    <textbox   id="CUSTOMDIALOG_SITEID" dataattribute="SITEID" lookup="site"/>
    </section>
    <buttongroup id="viewhist_2e">
    <pushbutton default="true" id="viewhist_e2_1" label="OK" mxevent="CUSTOMACTION"/>
    <pushbutton  id="viewhist_e2_d1" label="Cancel" mxevent="dialogcancel"  />
    </buttongroup>
    </dialog>
    and the script DATABEAN.CUSTOMDIALOG is created with beanid and beanapp variables as below :
    def CUSTOMACTION(ctx):
        ctx.closeDialog()
        ctx.setEventHandled()
    Thanks in advance.
    Amir


    ------------------------------
    Amir Nadi
    CCC
    ------------------------------



  • 11.  RE: MSUG - Automation Scripts in Maximo Application Suite

    Posted 01-02-2024 10:24

    I'm not sure I quite understand the use case of an action when there is no MBO in the dialog nor list tab. But regardless, without creating the signature option (because a signature option will lead to issues evaluating the signature option when there are no MBOs to evaluate) I tested this in the Asset application using the Maintenance Cost Rollup dialog since that is a dialog that can be opened with no records on the list tab. Next to the roll up all costs action, I added a new push button that invokes CUSTOMACTION. 

    My databean script looks like this:

    def CUSTOMACTION(ctx):
        ctx.setEventHandled()
        ctx.closeDialog()
        ctx.error("emx","test")

    With the variables defined like this:

    The push button in the dialog (NOTE: no signature options were configured in the advanced tab)

    Then when I click the Custom Action it closes the dialog and throws the error (whether there are records or not). 



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