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
------------------------------
Original Message:
Sent: 05-15-2025 17:30
From: Viet Tran
Subject: Refactoring Hundreds of Scripts
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
------------------------------