servervariablenames(
DATABASE
)

The servervariablenames( function returns the names of all server variables associated with a database.


Parameters

This function has one parameter:

database – name of the shared database that contains the server variables. If this parameter is missing or empty, the current database is assumed.


Description

This function returns the names of all server variables associated with a database. Each name is separated by a carriage return. Depending on your network speed and how busy the server is, there may be a slight delay before this function returns the requested list (however there is no delay if this function is run on the server in web code).

This example checks to see if a server variable named AreaCode exists, and if so, assigns it to a local variable. If it doesn’t exist, the area code 714 is used.

let areacode = "714"
if arraycontains(servervariablenames(),"AreaCode",cr()
    areacode = servervariable("AreaCode")
endif

Note: The example above illustrates how this function works, but it is a bit contrived, because there is a much shorter way to perform this task using only the servervariable( and catcherror( functions, as shown below. Not only is the code shorter, but it also requires only one network access, instead of two:

let areacode = catcherror("714", servervariable("AreaCode"))

The servervariablenames( function normally returns a list of server variables in the current database, but you can specify a different database if you want. The specified database must be a shared database, and it must be currently open. Here is a revised version of the previous contrived example that accesses the server variables in the Contacts database instead of the current database.

let areacode = "714"
if arraycontains(servervariablenames("Contacts"),"AreaCode",cr()
    areacode = servervariable("Contacts","AreaCode")
endif

Once again, there is a shorter way to perform this task.

let areacode = catcherror("714", servervariable("Contacts","AreaCode"))

See Also


History

VersionStatusNotes
10.2NewNew in this version.