How To retrieve servername and servertype?Author: Luc Van Dyck
Starting from Navision Attain 3.01, the C/AL function CONTEXTURL is available. This function
returns a context string that defines the current position of the running objects.
Example: navision://client/run?database=filename&company=companyname&servertype=NAVISION
navision://client/run?servername=server&company=companyname&servertype=MSSQL
When connected to a server (both Navision and SQL), this string contains the servername and
servertype ('NAVISION' or 'MSSQL').
The function fctGetServerName returns the servername or '' when connected to a local database.
The function fctGetServerType always returns either 'NAVISION' or 'MSSQL'.
fctGetServerName() : Text[30]
ltxtTemp := CONTEXTURL;
i := STRPOS(ltxtTemp,'servername=');
IF i > 0 THEN BEGIN
ltxtTemp := COPYSTR(ltxtTemp,i + 11,999);
i := STRPOS(ltxtTemp,'&');
EXIT(COPYSTR(ltxtTemp,1,i - 1));
END
ELSE
EXIT('');
fctGetServerType() : Text[30]
ltxtTemp := CONTEXTURL;
i := STRPOS(ltxtTemp,'servertype=');
IF i > 0 THEN
EXIT(COPYSTR(ltxtTemp,i + 11))
ELSE
EXIT('');