This is always a tricky area.
The weaknesses listed for the OOB functionality are pretty much spot on - doing things properly can be time consuming and frustrating.
The benefits miss out a positive – the OOB functionality gets tested by IBM.
While the testing has its limits it is certainly useful it will be preventing some issues.
The automation script weaknesses you list are dangerously incomplete / flawed.
The biggest scripting weaknesses that aren't covered are:
- IBM Support will not look at a case where custom code, e.g. a script, has fired
- Resource leaks
- Spaghetti code – this is hinted at
- Easier to bypass change control procedures
IBM Support will not look at a case where custom code, e.g. a script, has fired
--
They won't support a problem in a script – This is understandable but it would get painful for this organisation if the developer moves on and the replacement doesn't have lots of experience with scripts
IBM won't look at an unrelated problem if a script has executed e.g. A script is triggered while saving a WO. The script simply changes one value on a custom field (i.e. nothing that the core Maximo code will interact with) and then calls the MBO Save operation – the MBO Save then fails because of a problem with the core code.
In this case the customer has to replicate the problem without involving the script – that can be very difficult.
Spaghetti code
--
This is one of the biggest weaknesses of code – it gets very difficult to trace which scripts are interacting with a transaction.
If scripts aren't designed properly then they can become a nightmare e.g. if there are 5 scripts triggered by a WO save. One aspect that people forget is that there is no way to predict/control the order of script execution.
So the first time you save the WO the scripts could fire like this:
Script1, Script2, Script3 …
The second time it could be like this:
Script1, Script3, Script2 …
And the third time…
Script4, Script3, Script2 …
So you have to design your scripts so they can run completely independently and safely….
OR you merge scripts together so you control the flow…. – this is the ideal solution from Support's position / future maintenance
Developers tend to avoid merging the scripts because it is a lot more work and it means more retesting…
I am working on a capability that will trace the execution flow and highlight things that could be impacted e.g. which automation scripts / domains etc – it is a very complex task particularly when you realise that a line of automation script code could implicitly trigger other scripts e.g. by saving a workorder.
Its all in one place – for now.
--
Having the scripts in one place is fine for now but the developer can't guarantee that the next person will be as comfortable with scripts or that the organisation won't strictly enforce a rule to move back to OOB functionality
It is easy to see how rising script maintenance costs will lead to a management rule to use OOB functionality where possible
Resource leaks
--
Writing Automation scripts is relatively easy but Maximo's complexity means that it is also easy to create memory leaks that over time will degrade the performance of a JVM or kill it completely.
I spend a significant portion of my time investigating these even with my powerful toolset.
Vetasi offer an automated service to check automation scripts for bad practices / potential leaks. We also have automated tools to speed up the process of resolving performance problems.
Easier to bypass change control procedures
--
It is much easier to implement a "quick fix" to a script and so bypass change control procedures.
Change controls are important to help ensure that things are tested and that administrators understand what things could be causing a problem e.g. If this worked last week then what changed in the last 7 days?
Ultimately each organisation needs to make a decision about the best way forward.
Personally I prefer using the OOB features where possible.
------------------------------
Mark Robbins
Support Lead/Technical Design Authority / IBM Champion 2017 & 2018 & 2019 & 2020 & 2021
Vetasi Limited
https://www.linkedin.com/pulse/maximo-support-advice-from-non-ibm-engineer-article-mark-robbins/------------------------------
Original Message:
Sent: Mon October 04, 2021 11:19 PM
From: User1971
Subject: Logic in tables vs. hardcoded scripts
SUMMARY:
Mark Robbins pointed out that a better title for this post might be:
I'm frustrated with the time that is required for adding logic via OOB functionality vs. automation scripts.
To put it frankly, I'm giving up on putting logic in tables and using OOB mechanisms (like formulas and crossover domains). Instead, I plan to hardcode/customize Maximo with automation scripts -- since that seems to be the more practical option.
DETAILS / OPTIONS:
I have a long list of fairly simple requirements like this:
If the top level of the WO classification is FLEET, then set WORKORDER.FLOWCONTROLLED to 1.
My initial thoughts on how to implement that would be:
Option #1:
Put the logic in a table (and use OOB functionality like a crossover domain):
- Add a custom FLOWCONTROLLED YORN field to CLASSSTRUCTURE.
- (Or alternatively, create a custom DIVISION table and add a FLOWCONTROLLED field. This table would also be useful for a number of other requirements. I'd need slightly different mechanisms for auto-population than what I have below.)
- Batch update CLASSSTRUCTURE.FLOWCONTROLLED to 1 where the top level of the classification is FLEET.
- I would do this using MxLoader.
- Set up a crossover domain to auto-populate WO.FLOWCONTROLLED when the classification is modified in the WO.
- In reality, we would use an automation script (existing) instead of a crossover domain, since we've found Maximo doesn't always honor crossover domains when creating WOs (buggy). For example, crossover domains aren't honored when a WO is created via a PM/JP/route.
- Deploy and apply the changes to all environments (6).
- The new FLOWCONTROLLED field in CLASSSTRUCTURE will require a db config outage.
- I would apply db config changes myself to non-clustered environments (4).
- We would need to plan/coordinate with the WebSphere team to get them to apply db config changes to the clustered environments (2). This involves after-hours work (after midnight; overtime) and of course, a system outage.
I'm under the impression that it's best to put logic in tables when we can, and use OOB functionality, instead of hardcoding the logic in code (i.e. automation scripts).
Benefits of putting logic in tables (like CLASSSTRUCTURE) include:
- OOB functionality is easier to read/understand than code.
- DRY - Don't repeat yourself. We only need to enter the logic into the table once.
- It's easier to make bulk updates to tables, than it is to make bulk updates to code.
- It would be easy to refine the logic. For example, if the requirement changed and only some of the FLEET WO classifications required flow control, it would be easy to refine the data in CLASSSTRUCTURE by setting some of the FLOWCONTROLLED values to 0 instead of 1.
- Database tables and OOB functionality can be easily upgraded. Code is much harder to upgrade.
- My organization considers automation scripts to be customizations. And customizing systems is a violation of corporate policy. Ideally, I would put logic in tables, and use OOB functionality, to avoid violating corporate policy.
A note about attribute formulas:
I've pretty much given up on attribute formulas as an alternative to automation scripts. I gave formulas a fair shot, but I've found them to be too limited and too buggy. IBM plans to fix some of the bugs in future releases, but that doesn't help me right now. Especially since my organization doesn't have the resources to do the testing that would be required to apply iFixes or upgrade to 7.6.1.3 -- at least not in the near term. There would be too many problems to deal with, especially with Maximo add-ons.
Tradeoffs:
To be honest, option #1 is way too much work -- since it involves db config changes (including clustered environments). It would require many hours of effort from admins and the WebSphere team. Not to mention an outage.
Option #2:
Hardcode the logic in code (automation scripts)
In contrast, I think I could implement the requirement quite easily by hardcoding the logic in an automation script. I don't actually work with automation scripts much yet, but I'm guessing a line or two of code would do it:
- If WO.DIVISION is modified, and if the WO.DVISION = FLEET, then set WO.FLOWCONTROLLED to 1.
Benefits to hardcoding the logic in scripts:
- Takes minutes, not several hours/days.
- No db config outage required.
- I could easily make the change myself, by pasting that script into all 6 environments.
- All logic is in one place -- in the Automation Scripts application.
- If we're wondering what mechanism is responsible for populating a custom field, we know where to look -- automation scripts. There isn't any hidden functionality in formulas or crossover domains that we forgot about.
Tradeoffs:
- We don't get any of the benefits from #1.
- Code is difficult to maintain.
- I'm essentially saying, "screw you!" to the next guy who has to maintain the system and eventually upgrade it. That poor soul has no idea what's coming.
THOUGHTS:
To be honest, I'm a bit sad that I've come to this conclusion. I'm basically choosing to manage Maximo the wrong way...since the right way is turning out to be impractical. Goodbye data-driven/OOB best practices, hello unmaintainable code! :)
FOLLOW-UP QUESTION:
How does this compare with your experience? What do successful practitioners end up doing in the long run?
#Maximo
#AssetandFacilitiesManagement