Maximo Open Forum

 View Only
  • 1.  Script Debugging

    Posted 04-01-2025 07:31

    We are in a SaaS environment with no direct access to logs. Are there other methods to debug? Looking for something as simple as a message box. I've tried using service.error, but that halts execution of the rest of the script.


    #Administration

    ------------------------------
    Jason Johnson
    RSI
    ------------------------------


  • 2.  RE: Script Debugging

    Posted 04-02-2025 08:57

    hello,

    have you tried to use these?

        errorgroup='messageid'

        errorkey='messagekey'



    ------------------------------
    Poonam Aswani
    ltimindtree
    ------------------------------



  • 3.  RE: Script Debugging

    Posted 04-02-2025 09:19

    Yes, that's the format I am using. While it is useful for showing some data, it still stops execution.



    ------------------------------
    Jason Johnson
    RSI
    ------------------------------



  • 4.  RE: Script Debugging

    Posted 04-02-2025 10:00
    Hi Jason - I've used something similar to this in the past, if I was looking for something quick and simple:
    from com.ibm.tivoli.maximo.script import ScriptService
    service = ScriptService("MVN.LOGGING.TEST", None, None)
    # Variable to hold log message.
    logs = []
    def addLog(s):
        # Set as String, so we don't get weird conversion errors.
        logs.append(str(s))
        
    def showLog():    
        # Use service varaible to raise exception.
        service.error("error", "\n".join(logs))
        
    # Add logs.
    addLog("First log message here.")
    addLog("Second different message.")
    addLog("Last message.")
    # Show error now.
    showLog()
    You should be able to call addLog to capture your messages in the script, and then at the end of the script, call showLog(), which just raises an exception to stop the script, but you should have visibility to the logs that were added during the execution.
    I hope this helps!


    ------------------------------
    Aaron Paroulek
    Maven Asset Management
    ------------------------------



  • 5.  RE: Script Debugging

    Posted 04-02-2025 10:50

    Hey Jason,

    We're using rsync to connect to the log bucket that IBM gave us access to.

    masms-pp-2-blah-blah-blah/Maximo/logs

    Created a scheduled task on an on prem win server that runs a powershell script that syncs that bucket with a local folder for log review.

    Seems to be working so far, been on SaaS for about 8 mths.

    Pete



    ------------------------------
    Pete Iadevaia
    Pima County
    ------------------------------



  • 6.  RE: Script Debugging

    Posted 04-02-2025 16:13

    You can append all the logs into a string, then write it to a Description or Long Description field. For example:

    strLog = 'Step 1 - myVar = %s' % (myVar)
    strLog = strLog + '<br>Step 2 - myVar = %s' % (myVar)
    strLog = strLog + '<br>Step 3 - myVar = %s' % (myVar)
    
    mbo.setValue('DESCRIPTION_LONGDESCRIPTION', strLog)



    ------------------------------
    Viet Tran
    Relia App Development & Consulting
    https://relia.app
    ------------------------------



  • 7.  RE: Script Debugging

    Posted 04-03-2025 09:08

    Thank you all. I think I've got a few methods now.



    ------------------------------
    Jason Johnson
    RSI
    ------------------------------



  • 8.  RE: Script Debugging

    Posted 04-03-2025 09:53

    Though its not very cleaner approach but in such situation where you don't have access to log , you can use below method to raise exceptions or print details from code at specific points to check if data/details are being driven by your logic or not. It will stop running code on first occurrence of this call and open dialog and print details your wanted to check 


    raise TypeError("Print Errorr"+mbo.getString("XXX"))



    ------------------------------
    Prashant Bavane
    ------------------------------



  • 9.  RE: Script Debugging

    Posted 04-03-2025 14:44

    Hi Jason,

    Our VS Code extension allows for streaming the log directly to your desktop within VS Code.  It works really well in a single Pod deployment, which is typical of development environments.

    https://marketplace.visualstudio.com/items?itemName=sharptree.maximo-script-deploy

    It is free and also makes the development process so much faster in a lot of other ways.  If you have any questions feel free to reach out.

    Jason



    ------------------------------
    Jason VenHuizen
    Sharptree
    ------------------------------