Creating a New User Attribute Type

To create a new user attribute type:

  1. Create an application class definition that extends the PTBR_BRANDING:UserAttributes:BaseUserAttribute class.

    Use the PTBR_BRANDING:UserAttributes:* class definitions as examples.

  2. Implement the following methods in the new class:

    • The class constructor to initialize the object.

      MyUserAttribute(ID as string)
    • getPromptViewName to return the record definition to be used as the search prompt view. If no search prompt view exists, return an empty string.

      getPromptViewName() Returns string
    • validateValue to return a Boolean value indicating whether the user has the specified attribute.

      validateValue(value as string) Returns boolean
  3. Create a new user attribute type definition.

    See Defining User Attribute Types.

Example

The following example provides the implementation of the PTBR_BRANDING:UserAttributes:RoleBasedUserAttribute class.

import PTBR_BRANDING:UserAttributes:BaseUserAttribute;
/**
  * RoleBasedUserAttribute Class
  */
class RoleBasedUserAttribute extends PTBR_BRANDING:UserAttributes:BaseUserAttribute
   /* --- Properties --- */
   /* --- Methods --- */
   method RoleBasedUserAttribute(&pId As string);
   method getPromptViewName() Returns string;
   method validateValue(&pValue As string) Returns boolean;
end-class;
/**
  * Constructor
  *
  * @param pId ID of the object.
  *
  */
method RoleBasedUserAttribute
   /+ &pId as String +/
   %Super = create PTBR_BRANDING:UserAttributes:BaseUserAttribute(&pId);
   %This.setUserAttributeType("RoleBasedUserAttribute");
end-method;
/**
  * Return the role prompt view name
  *
  * @return string - the prompt view name
  *
  */
method getPromptViewName
   /+ Returns String +/
   /+ Extends/implements PTBR_BRANDING:UserAttributes:BaseUserAttribute.getPromptViewName +/
   Return Record.PSROLEDEFN_SRCH;
end-method;
/**
  * Validate whether the current has this role
  *
  * @return boolean - the result
  *
  */
method validateValue
   /+ &pValue as String +/
   /+ Returns Boolean +/
   /+ Extends/implements PTBR_BRANDING:UserAttributes:BaseUserAttribute.validateValue +/
   Return IsUserInRole(&pValue);
end-method;