This blog post comes about because of LifeCycle Management ("LCM"). It's fine as a tool to migrate things (called artifacts) from one environment to another but I don't use it a lot because HFM has native import and export capabilities for most things already. LCM works better when the application has the same name in all environments, which I don't like: I like knowing where I am. 184.108.40.206 addresses this somewhat - if you're migrating from one HFM app to another and they're called different names and the LCM import doesn't find the same application name, it will prompt you to select one. But try this with a task flow and you won't get prompted and you'll end up with a task flow that doesn't work since the embedded application name didn't get changed (believe me, I tried).
The obvious answer to this is to call the application name the same in all environments, and most people do that. But here's the problem. Within rules, we typically want rules to do different things in dev vs. QA vs. production. If you're doing write to file, for instance, you'll want different file paths for each environment. If you're sending emails for your metadata diagnostics (you are sending emails for your metadata diagnostics, right?) we want to have different addresses, different email subject line, etc. If the application name is different, then you can use HS.ApplicationName to find out where you are. But if you're being LCM-friendly, that's not going to work.
So, what to do?
Fortunately, VB script has a way to find out where you are. You can use two simple lines to capture the computer name (server) that is running HFM. So, in your rules, do something like this:
set wshShell = CreateObject("WScript.Network")
strComputerName = wshShell.ComputerName
Then, after that, use if/then or select case to look at the computer name and set the path or whatever you're doing. If your environment has multiple HFM servers, then include all the server names.
Select Case strComputerName
location = "\\dev\fileshare\file.txt"
Case "PROD01", "PROD02"
location = "\\prod\fileshare\file.txt"
This allows you to know where you are and still be LCM-friendly. If you're running on Exalytics, you may need to tinker this a bit. I've had multiple Exalytics clients but for some reason they all still put HFM out on separate Windows servers - weird.
Anyway, have fun knowing where you are.