Sets or returns an environment variable stored in a formula.
@Environment( variable ) @Environment( variable ; value )
variable
Text or text list. The name of the environment variable you want to retrieve. To retrieve multiple environment variables, use a text list.
value
Text. Optional. The value you want to assign to the environment variable. Since users have their own notes.ini or Notes® Preferences file, this value can be customized for each user. Omit this parameter if you just want to retrieve the value, not set it.
environmentVariable
Text. The value of the environment variable you specified. To use the return value in arithmetic operations, use @TextToNumber to convert it to a number.
Use @Environment when you want to set an environment variable within a formula. If it's to be nested within another @function (such as @If or @Do), use @SetEnvironment instead.
The ENVIRONMENT keyword works the same as @Environment.
@Environment cannot be used in column or selection formulas; it's only intended for use in field formulas, toolbar buttons, and agents. Some formulas, such as scheduled agents, are run on the server instead of on the user's workstation. In this case, the environment variables affected are the server environment variables, not the workstation variables. You can use a computed text formula to retrieve variables, but not to set variables.
You can also use @Environment to get the value of an environment variable stored the user's notes.ini file (Windows, OS/2, and UNIX) or Notes Preferences file (Macintosh). You can only set and retrieve the values of variables that begin with a dollar sign ($) symbol. Do not include the dollar sign in the variable parameter. For instance, to change the value of the $EnableAlarms INI variable from 1 to 0, enter:
@Environment("EnableAlarms";"0")
For Web applications, use predefined field names to gather information about the Web user's environment by requesting Common Gateway Interface (CGI) environment variables.
@Environment("IEVersionMajor")
@Environment("OrderNumber";"0")
@Environment("ENVOfficeLocation")
Its input-translation formula is:
@Environment("ENVOfficeLocation"; OfficeLocation);
OfficeLocation
The first time the user creates a Profile document, the OfficeLocation field is blank, so the user types in the office location. When the document is saved, the contents of the OfficeLocation field are saved in the notes.ini or Notes Preferences file. The next time the user creates a Profile document, the office location is retrieved from the environment variable ENVOfficeLocation, and the user doesn't have to type it in again (unless the office location changes, in which case the user edits the field).
You could also write the input-translation formula using either @SetEnvironment or the ENVIRONMENT keyword, both of which achieve the same result:
@SetEnvironment("ENVOfficeLocation"; OfficeLocation);
OfficeLocation
or
ENVIRONMENT ENVOfficeLocation:= OfficeLocation;
OfficeLocation
@Environment("ENVBirthday")
Its input-translation formula uses @Text to convert the time value into text:
@SetEnvironment("ENVBirthday"; @Text(Birthday));
Birthday
Use @Text to write a similar input-translation formula for a number field.
Temporary := @Environment("OrderNumber");
Temporary2 := @If(Temporary="";"0";Temporary);
CurrentOrderNumber := @TextToNumber(Temporary2);
NextOrderNumber := CurrentOrderNumber + 1;
ENVIRONMENT OrderNumber := @Text(NextOrderNumber);
@Text(CurrentOrderNumber);
@If(@Environment(OrderNumber)=""; @SetEnvironment("OrderNumber";"0"); @Return(@Environment("OrderNumber")))
The Set Group agent looks up the list of group names stored in column 1 of the Service Requests - By Group view, prompts the user to select a group name, and then stores the selected name in the TmpName environment variable before running the "(Set Group Helper)" agent. The "(Set Group Helper)" agent then retrieves the group name from the user's notes.ini or Notes Preferences file and stores it in the Group name field for all selected documents.
Set Group agent executes once:
GroupList:=@DbColumn("":"NoCache";"";
"Service Requests\\By Group";1);
Group:=@Prompt([OKCancelEditCombo];"Choose a group";"Choose
a group";"Marketing";GroupList);
Tmp1:=@Environment("TmpName";Group);
@Command([RunAgent];"(Set Group Helper)");
(Set Group Helper) agent runs on each selected document:
FIELD Group:=@Environment("TmpName");
Environ function of LotusScript® language
GetEnvironmentString method of LotusScript NotesSession class
SetEnvironmentVar method of LotusScript NotesSession class
getEnvironmentString method of Java™ Session class
setEnvironmentVar method of Java Session class