• System variables in People code

    Posted on October 25, 2012 by in Other Programming, People Soft

    PeopleTools provides a number of system variables that provide access to system information. System variables in peoplecode 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.

    In this section, we discuss some of the most used system variables in People code. Please list of all the variables please click here

    List of frequently used System variables in People code

    Date Related

    %AsOfDate

    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

    %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.

    %Date

    %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

    %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.

    %Time

    %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.

    Component/Page Etc

    %Component

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

    %Page

    %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.

    %Mode

    %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. The %Mode is generally used to enable and disable depending whether is add mode or update mode.

    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

    User Related

    %OperatorId

    %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.

    %UserDescription

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

    %UserId

    %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.

    %EmailAddress

    This system variable returns the email address of the current user.

    %EmployeeId

    %EmployeeId returns an uppercase character string containing the Employee ID of the user currently logged on.

    %Roles

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

    %PermissionLists

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

    %RowSecurityPermissionList

    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.

    Menu Related

    %Menu

    %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.

    %LocalNode

    %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

    %Node

    %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.

    Other

    %Session

    %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.

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

    %currency

    This system variable returns the preferred currency for the current user.

    Be Sociable, Share!
      Post Tagged with

    Written by

    Vanamali Juvvadi is a Web enthusiast and loves all things design and technology. Founded qnownow with a group of friends to share anything/everything they know/find on the internet.

    View all articles by

    Email : [email protected]

    Leave a Reply