ENVIRONMENT (Formula Language)

A reserved word that sets or gets an environment variable stored in the user's notes.ini file (Windowsand UNIX) or Notes® Preferences file (Macintosh).

Syntax

ENVIRONMENT variable := textValue ;

Usage

To get the value of an environment variable, use @Environment. To set the value of an environment variable, you can also use @Environment, or you can use @SetEnvironment.

For Web applications, use predefined field names to gather information about the Web user's environment by requesting Common Gateway Interface (CGI) environment variables.

Examples

  1. This example returns 5, if that is the value of the variable $IEVersonMajor stored in the current user's notes.ini or Notes® Preferences file.
    @Environment("IEVersionMajor")
  2. This example places a variable called OrderNumber in the current user's notes.ini or Notes® Preferences file, and assigns it a value of zero.
    @Environment("OrderNumber";"0")
  3. To save users time while completing Profile documents, you might want to automatically fill in an office location for them. You can create an editable text field called OfficeLocation. Its default formula is:
    @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
  4. In addition to the OfficeLocation, you might want to use an environment variable to store a user's birthday. You can create an editable time field called Birthday. Its default formula is similar to the one used for 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.

  5. You want to generate sequential numbers on a per user basis, and you want to store the number in a field called OrderNumber. Define the field OrderNumber to be a Text data type; it must be some form of computed field. You can then write the following formula for the field.
    Temporary := @Environment("OrderNumber");
    Temporary2 := @If(Temporary="";"0";Temporary);
    CurrentOrderNumber := @TextToNumber(Temporary2);
    NextOrderNumber := CurrentOrderNumber + 1;
    ENVIRONMENT OrderNumber := @Text(NextOrderNumber);
    @Text(CurrentOrderNumber);
  6. This formula tests whether an environment variable called OrderNumber has been stored in the user's notes.ini or Notes® Preferences file. If there is no such variable stored, @SetEnvironment initializes it to zero. If a value has already been stored, @Return returns it and stops the formula from executing.
    @If(@Environment(OrderNumber)=""; @SetEnvironment("OrderNumber";"0"); @Return(@Environment("OrderNumber")))
  7. Two agents are used to look up a list of possible group names that users might belong to, prompt the user to select one, and then enter that name in the Group field for all selected documents (which, in this case, pertain to the current user).

    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");