On a multisite Epicor installation, it is VERY important to control the site for which your epicor function is running on. You wouldn’t want your inventory transfer or your order to be shipped for the wrong site.
Epicor has this ‘feature’ that if your user switches site on the epicor client and then you close the client. The next time you open the client again it will remember the last site you were on. The same is true for a function. Which is truly awful. To avoid this behavior, I always have a site/plant parameter in every one of my functions:

And the first block of custom code in my epicor function is

The content of that block is a single line of code

CallContext is a global object available anywhere in your epicor function but it’s best to set it right away. The rest of the function will execute under the parameter selected site.