Maximo Open Forum

 View Only
  • 1.  Refactoring Hundreds of Scripts

    Posted 29 days ago

    Hello everyone!

    Our company's been going through some big changes lately, and one of them is removing hardcoded site values from our automation scripts (250 of them). We've started using a conditional expression to check if the site is in a specific list, something like mbo.evaluateCondition("ourcondition"), and then use that in if statements and dynamic queries.

    The tough part now is testing each script to make sure everything still works the same as before. We're thinking of reading through each script, setting up a scenario, and checking if the outcome matches what it should do-which honestly sounds like a pretty time-consuming process.

    I tried using the "Test Script" feature in the Automation Scripts app, but it's missing some key stuff like appname or interactive.

    Anyone dealt with something similar? How would you go about testing these scripts efficiently?


    #Customizations

    ------------------------------
    Victor G
    acw
    ------------------------------


  • 2.  RE: Refactoring Hundreds of Scripts

    Posted 28 days ago

    It's not a direct answer you are asking for, but I suggest you not to do that.

    Moving a hard-coded site ID from an IF statement into an Expression Condition is still hard-coding. It just shifts the logic to a different place. It also adds another layer of complexity. Now, instead of reading the logic directly in the script, you have to jump into another application to understand what the condition does, then come back to the script to see how it fits in.

    I refactoring automation script all the time. Often, it starts with refactoring one or two scripts when adding a new feature. But I've also done full system-wide refactoring a few times.

    My approach usually starts with listing all automation scripts in a spreadsheet. I do a quick high-level review of each to understand what it does and whether it should be removed, refactored, or replaced. Then I prioritize the actions and tackle them one by one.

    Once you start, it's often easier than you expect.



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



  • 3.  RE: Refactoring Hundreds of Scripts

    Posted 27 days ago

    I would be wary about using Excel to store the automation scripts.

    I have seen cases where Excel silently truncated the script text because it breached the number of characters allowed in a cell.

    Consider using a BIRT report to extract the text.

    In our case we use a BIRT report to export the script so we can control the format & how it is used.

    Then we have an automated process that reads the export and highlights problems etc



    ------------------------------
    mark robbins
    Cohesive
    IBM Champion 2017-2024 Inclusive
    See my blog on Maximo support related topics here:
    https://www.linkedin.com/pulse/maximo-support-advice-from-non-ibm-engineer-article-mark-robbins/
    ------------------------------



  • 4.  RE: Refactoring Hundreds of Scripts

    Posted 27 days ago

    I meant using Excel solely to maintain a list of scripts, including summary, priority, action, etc., not to store the actual script code in the spreadsheet. The main purpose is to get a high-level understanding before refactoring any individual script.

    The key point is I disagree with the approach of moving logic into Condition Expressions using evaluateCondition. It only makes sense when the condition involves a complex SQL query that's too difficult to interpret within an automation script, or when the query is specifically designed to leverage the database structure and indexes for better performance.



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



  • 5.  RE: Refactoring Hundreds of Scripts

    Posted 23 days ago

    Is there something special about that site / those sites? Why not make an attribute of SITE to capture that "something special"? Then your code can test for whether the site this record belongs to has that attribute set to indicate that it needs special treatment? Then you don't have to hard-code any sites in any conditions.



    ------------------------------
    Blessings,
    Jason Uppenborn
    Cohesive
    ------------------------------



  • 6.  RE: Refactoring Hundreds of Scripts

    Posted 21 days ago

    Hi Jason,
    These sites belong to a specific business "branch" and already have a flag that identifies them as part of that group. Our condition checks for this flag, but it needs to be included in multiple scripts



    ------------------------------
    Victor G
    CNZ
    ------------------------------



  • 7.  RE: Refactoring Hundreds of Scripts

    Posted 21 days ago

    Hi Vien Tran, 
    The purpose of the conditional expression is to allow the addition of new branches as they are acquired by the company. These sites already have a flag that identifies them as belonging to a specific group of branches. This means that whenever the company acquires a new branch, we can simply enable that flag on the site, and the expression will include it automatically.

    We have already identified all the relevant scripts, ordered them by complexity, and found several large scripts-some with many lines-that use hardcoded IF statements for specific sites. These will be replaced with the conditional expression. Additionally, some relationships inside the scripts will be changed from something like WORKTYPE = 'Z' AND SITEID IN ('A', 'B') to WORKTYPE = 'Z' AND {our conditional expression evaluation}.

    As you can imagine, handling these changes manually can be prone to human error, which is why we need to thoroughly test each one.



    ------------------------------
    Victor G
    CNZ
    ------------------------------