Saturday, June 4, 2011

Most Frequently Used System Variables


Post Level         : Advanced/Must to Know
Target Readers : Beginners to Experts


PeopleTools provides a number of system variables that provide access to system information. System variables are prefixed with the ‘%’ character, rather than the ‘&’ character. You can use these system variables wherever you can use a constant, passing them as parameters to functions or assigning their values to fields or to temporary variables.

There are 79 system variables in PeopleTools(8.49). In this section, we will discuss 31 the most frequently used system variables.

%AsOfDate
Description
Returns the as-of-date of the environment that the PeopleCode is running in. In most cases, this is the current date, but for Application Engine environments, it is the processing date of the Application Engine program.

%ClientDate
Description
%ClientDate returns the current date for the current user, adjusted for the user’s time zone. This is the date as specified with the current user's personalizations.
You can use this system variable as the default constant for a date field.
This is potentially one day different than the server date, which is returned with %Date.



%Component
Description
%Component returns an uppercase character string containing the name of the current component, as set in the component definition.


%Currency
Description
This system variable returns the preferred currency for the current user.


%Date
Description
%Date returns a Date value equal to the current server date. This is potentially different than the client date, returned by %ClientDate. You can use this system variable as the default value for a date field.


%DateTime
Description
%DateTime returns the current server date and time as a Datetime value.
Note. This variable does not return actual milliseconds. It always returns zeros for the millisecond value.

%EmailAddress
Description
This system variable returns the email address of the current user.


%EmployeeId
Description
%EmployeeId returns an uppercase character string containing the Employee ID of the user currently logged on. This is typically used to restrict access to an employee's own records.


%IsMultiLanguageEnabled
Description
This system variable returns True if the current user is multi-language enabled.


%Language
Description
%Language returns a string value representing the current session's language as selected from the signon page.
Note. This function remains for backward compatibility only. Use the %Language_User system variable instead.

%Language_Base
Description
%Language_Base returns the base language for the current database, as set with the PeopleTools Options page.


%Language_Data
Description
If multi-language entry is enabled, %Language_Data returns a string value representing the current data language selected by the user.
If multi-language entry is not enabled, %Language_Data returns the current session language.
Use %Language_Data if your application must know the language any entered application data is stored as in the component's related language records. Do not use this variable to control the user interface, such as messages or page text. For determining the language of the user interface, use the %Language_User variable.


%Language_User
Description
%Language_User returns a string value representing the current session's language as selected from the signon page. This value can be changed for the current session with the SetLanguage function.
Note. The value of this system variable may not reflect the current data language if the user has multi-language entry enabled.

%LocalNode
Description
%LocalNode returns the name of the local node for the current database as a string.
For example, suppose your PeopleCode is part of the page USERMAIN_SELF, in this URL:
http://serverx/servlets/psp/eprocurement/hrms/c/MAINTAINT_SECURITY.USERMAIN_SEF.GBL
This system variable returns the following:
hrms

%Menu
Description
%Menu returns an uppercase string containing the current menu name. It can be used to restrict edits or processing to a specific menu.
Note. Do not use the %Menu variable in the SearchSave event. You may get unexpected results.

%Mode
Description
%Mode returns a String value consisting of an uppercase character specifying the action a user selected when starting the current component. The following values can be returned. You can check either for the string value ("A", "U", and so on.) or for the constant:
Numeric Value
Constant Value
Description
A
%Action_Add
Add
U
%Action_UpdateDisplay
Update/Display
L
%Action_UpdateDisplayAll
Update/Display All
C
%Action_Correction
Correction
E
%Action_DataEntry
Data Entry
P
%Action_Prompt
Prompt
Note. This system variable is not valid with mobile PeopleCode.

%Node
Description
%Node returns the name of the node from the current request object. This variable can only be used with in a request (%Request). If you need to get the node name for a message, use the PubNodeName message property instead.


%OperatorClass
Description
This system variable returns a string representing the primary or base class of the current operator.
Note. This system variable is supported for compatibility with previous releases of PeopleTools. New applications should use %PermissionLists instead.

%OperatorId
Description
%OperatorId returns an uppercase character string containing the operator currently logged on. This is typically used to restrict access to records or fields to specific operators.
Note. This system variable is supported for compatibility with previous releases of PeopleTools. New applications should use %UserId instead.


%OperatorRowLevelSecurityClass
Description
This system variable returns a string representing the row-level security class of the current operator. The row-level security class is now distinct from the operator’s primary class.
Note. This system variable is supported for compatibility with previous releases of PeopleTools. New applications should use %RowSecurityPermissionList instead.

%Page
Description
%Page returns an uppercase character string containing the current page name. It is typically used to restrict processing to a specific page, which is often necessary, because PeopleCode programs are associated with record definitions that can be shared by multiple pages.


%Panel
Description
%Panel returns an uppercase character string containing the current panel name.
Note. This system variable is supported for compatibility with previous releases of PeopleTools. New applications should use %Page instead.

%PanelGroup
Description
%PanelGroup returns an uppercase character string containing the name of the current component, as set in the component definition.
Note. This system variable is supported for compatibility with previous releases of PeopleTools. New applications should use %Component instead.

%PasswordExpired
Description
This system variable returns a Boolean indicating if the current user's password has expired. This system variable should be used after using SwitchUser, to verify if the password of the user that the user has just switched to is expired.


%PermissionLists
Description
This system variable returns an array object containing entries for all the permission lists to which the current user belongs.


%Roles
Description
This system variable returns an array object containing entries for all the roles to which the current user belongs.


%RowSecurityPermissionList
Description
This system variable returns a string representing the row-level PermissionList of the current user. The row-level security PermissionList is distinct from the user’s primary PermissionList.

%Session
Description
%Session returns a reference to the current, existing session. If you use %Session successfully, you don't have to use the GetSession function and Connect method. If you don't have a current session, %Session returns NULL.
Example
Local ApiObject &MySession

&MySession = %Session;
If Not (&MySession) Then
   /* Application level error handling */
End-If;
The following example is used with in a mobile application:
Local ApiObject &ob, &Session;
Local ApiObject &PropertyInfo;

&ob = %ThisMobileObject;
&Session = %Session;

&SaveCustomer = %ThisMobileObject.MyFavoriteCustomer;

&Customer = %Session.GetCompIntfc(COMPINTFC.CUSTOMER);
&Customer.Name="Acme Applicances";


%Time
Description
%Time retrieves the current database server time.
If your application deals with time-sensitive data, use this value. If you want to measure the performance of a PeopleCode program, use the %PerfTime system variable instead.


%UserDescription
Description
This system variable returns the description (if any) listed for the current user.


%UserId
Description
%UserId returns a character string containing the user currently logged on. This is typically used to restrict access to records or fields to specific users.


Excerpt from :
Home > PeopleBooks > Enterprise PeopleTools 8.49 PeopleBook: PeopleCode Language Reference > System Variables


Please leave your helpful comments...

No comments:

Post a Comment