I am building up a URL in a data directive to be used downstream as a link in an email notification.
I am struggling to find a way to access the App Server URL from the Data Directive. I have tried Session.AppServerURL (I have seen it suggested for use in Form Customizations and Method Directives), but in the Data Directive it is returning an empty string.
Has anyone had success doing this, or have any other ideas to try?
Yes, this is an interesting problem indeed and maybe someone else has solved it. Just some thoughts:
The biggest issue is that there may be several app servers (and hence URLs) that service this application: like a web farm, a proxy service (like Azure Front Door, etc.), or multiple app servers for different authentication protocols (possible less of an issue with 2022+), and instances (Prod, Test, Pilot, …) How can you pick the correct one?
We could grab an app server URL from the Task Agent, if it is populated and we don’t have the problem above.
The one place where it is known is from the calling client. If the directive is triggered by user-action, you might be able to send the Session.Url in the BPM Context area.
Maybe there’s a programmatic way to access the web.config/configuration info.
Least desirable, put a file on the server in EpicorData with the app Server URL you want to use. A backup/restore would not overwrite it. It could be easily created with a REST call.
In the Company module, add a field to the Email section for it. It would have to be updated for backup/restores…
We enter an Epicor Idea and ask for this as a callable function.
I ended up using a UD table to store a variety of custom Settings that we use in our BPMs, Data Directives, Functions, and Customizations. I added our primary App Server URL as a record in the UD table and retrieve it from there when building up a link URL.