Hugo Pinheiro wrote:
Hi Hugo,
I tried this solution. But this doesn't seem to work.
I am using Outsystems 10.
Regards,
Keya Madhukar
Hello Keya,
where are you trying to use the action? Additionally, there are other options that you can explore, for instance, have a site property with the server url and then have a function to share it with other modules.
Best Regards,
Hugo Pinheiro
I am trying to access the same in the client action of a mobile application. Using the GetServerName server action logs a blank string in service center. I do not want to hardcode the server details as I want it to be accessible across all environments (for which the URL can be different). Hence I cannot put it as a site property.
Thanks for the information.
You don't even have to create a extension. the CurrentServerName, is registered in the system Parameter entity, reference the entity and you can use a Aggregate and filter on
Parameter.Name = "DefaultDNSName"
Will mark this question as Solved and Close the Post now;
Happy Low Coding!
Hello. On the version 6.0, on Rich Widgets there is an action (called GetServerName) that returns the server name. Regards, Zaida Pires
Here's an other way to check your domain name / ip-address.
First get the URL with the action "GetURL". (If you don't see this action, make sure you have it's reference added to your application. It can be found in the HTTPRequestHandler producer.)
Then you can use the return value of this GETURL action in an IF statement to check if a certain IP or domain name is part of it's URL.
Code Snippet IF statement
Index(GetURLName.URL,"1.1.1.1") = -1
If the IP address you are looking for is NOT part of the url it will return the value -1
Hello Keyta,
you are right, seems that the GetServerName is not working on mobile, also tested and returns an empty string, please open a support case with this.
Regarding the solution with site properties, yes you need to change it in the different environments, but it's only once.
I was able to get the current server name via the function GetRequestDomain from the system component HTTPRequestHandler. see below the information returned from several functions from that particular API, for an example:
To reference this action just open the dependencies manager and select the function for you to be able to use it in your code:
GetRequestDomain does not answer the question in the OP as it returns localhost when called from a timer action.
Sorry for reviving an old post but feel free to try out this new component that solves this even inside BPTs, Timers, etc, anywhere you may need.
https://www.outsystems.com/forge/Component_Overview.aspx?ProjectId=11293&ProjectName=get-server-url-dynamically
This thread is over a decade old, but still highly ranked when searching for "OutSystems current server name" or "OutSystems machine name".
Nowadays, you have the option to create an Action in a XIF that returns the MachineName property of the .NET System.Environment class. It matches the same name shown under Service Center > Environment Health, as well as the data in the Server entity from (System).
/// <summary> /// Returns the name of the current server. /// </summary> /// <param name="ssServerName">Current server name.</param> public void MssCurrentServerName(out string ssServerName) { ssServerName = Environment.MachineName; } // MssCurrentServerName
Tested it and it also works in non-user contexts (e.g. Timers).