In an Epicor Cloud environment it seems that the Epicor application and the task agent both run on a different Appserver. For example if I run an Epicor function, triggered from a BPM, and print the Session.AppServerUrl it will show the AppServerUrl of the Epicor Application. This is the same one as I see in my Epicor application in the top right corner.
But when I trigger the Epicor Function with the Schedule Epicor Function program it will be executed through the Task Agent and will return a different AppServerUrl.
Would it be possible to get the AppServerUrl of the Epicor Application (the one we see at the top right corner) from a scheduled function? How would I Achieve this?
Hi Brian,
What about adding an input parameter to your function and sending in the appserver URL?
I believe you can set a parameter for the scheduled function and mark it as recurrent so it will always use the same param, so you only enter it once.
Another option is to store your AppServerURL on a custom UD field and access it within the function via Db query.
These two options would definitely make it possible, but it would make my solution a bit less dynamic, since it would require me to enter the ‘original’ appserver url hardcoded in either the function parameter or the UD field. In the end I would like to use this solution in multiple environments.
The ideal solution would be retrieving the AppServerUrl from somewhere in my function.
If this is not possible i’ll probably use your first option!
Thank you for replying.
I understand that there can be many appservers on the same Epicor instance. In this case I want to get the appserverurl from the appserver that scheduled the Epicor Function. But i am retrieving the appserverurl from the appserver that is executing the task (Task agent).
Long story short: The reason why I want to retrieve this, is because I have an external application with a database that holds the appserver url from multiple environments. I would like to match the outputs of the function with the data in this external database, based on the appserverurl.
There is no way to do that. The current process (Agent) is the App Server you have there is no way for you to find a 3rd other un-related AppServer from a given process that could be a completely different machine or server.
And the system agent doesn’t have to be aware of that nor would it know if there are others. For all intents and purposes YOUR app server at the time of execution is the AppServer that matters to your function.
Right that’s a hack that gets you the appserver at the time of scheduling but even that wouldn’t catch others if you are behind something like a load balancer.
I still don’t see the point clearly of what this accomplishes that you can’t do with the AppServer URL of the sysagent.
Unfortunately I can’t share the details of the project, but the idea is that I want to identify the environment and compare it to an external SQL database to retrieve some records based on the appserverurl that is stored in there. Your replies did send me in the right direction.
I have now created a Pre-processing method directive on the ‘Ice.Proc.ScheduledFunction.SubmitToAgent’ method which looks like this:
Since I will be the one who will schedule this function (once), I can make sure that it will be scheduled from the ‘correct’ appserver. So for my use case it will work as intended.