User Attributes are a nice feature of the PeopleTools Branding framework. User Attributes allow us to conditionally apply Portal Branding Themes in a context-sensitive manner. Examples of delivered User Attributes types are the Role and Permission List types which allows for Role and Permission List based theme assignments. The PeopleTools Branding framework provides the ability to define your own custom User Attribute Types. I will outline the required steps to define a custom User Attribute that allows for user preference-based theme assignments. This post is a continuation of my previous two posts that describe how Personalization Options can be leverage to provide your users with a preference-based experience.
The end goal functionality is to allow end-users to specify a theme (Tangerine, Fluid, Red, Blue, etc.) that they prefer and for the system to conditionally assign the theme based on the user’s preferred theme. In my previous post I covered how to enable the Portal Branding Theme selection drop down on the end-user My Preferences page:
All that is needed now is some Application Class PeopleCode and a little bit of configuration to connect the user preference selection to a custom User Attribute.
The first step in creating a custom User Attribute is to create a class that extends the delivered PTBR_BRANDING:UserAttributes:BaseUserAttribute base class. The custom class will implement the getPromptViewName and validateValue methods of the base class. The getPromptViewName method returns the table name (PTBR_THEME) to be used in the prompt on the Assign Themes page and the validateValue method is responsible for performing the logic in determining if a particular theme needs to be assigned to a user during a session. As you can see in the code below, the GetUserOption function is used to read in the user’s preferred theme description that ultimately determines the theme assignment.
import PTBR_BRANDING:UserAttributes:BaseUserAttribute; class PreferenceBasedUserAttribute extends PTBR_BRANDING:UserAttributes:BaseUserAttribute method PreferenceBasedUserAttribute(&pId As string); method getPromptViewName() Returns string; method validateValue(&pValue As string) Returns boolean; end-class; method PreferenceBasedUserAttribute /+ &pId as String +/ %Super = create PTBR_BRANDING:UserAttributes:BaseUserAttribute(&pId); %This.setUserAttributeType("PreferenceBasedUserAttribute"); end-method; method getPromptViewName /+ Returns String +/ /+ Extends/implements PTBR_BRANDING:UserAttributes:BaseUserAttribute.getPromptViewName +/ Return Record.PTBR_THEME; end-method; method validateValue /+ &pValue as String +/ /+ Returns Boolean +/ /+ Extends/implements PTBR_BRANDING:UserAttributes:BaseUserAttribute.validateValue +/ Local Record &rBrandingTheme = CreateRecord(Record.PTBR_THEME); &rBrandingTheme.PTBR_THEME_ID.Value = &pValue; &rBrandingTheme.SelectByKey(); Return (GetUserOption("CSTM", "PSM_THEME") = &rBrandingTheme.DESCR.Value); end-method;
Once the custom User Attribute PeopleCode has been placed in an Application Class, the User Attribute class will need to be registered in PIA. Navigate
Main Menu > PeopleTools > Portal > Branding > System Data > Define User Attribute Types. Define the PREFERENCE_BASED User Attribute type and populate
the Supporting Application Class fields accordingly.
Once this is complete, you can navigate to
Main Menu > PeopleTools > Portal > Branding > Assign Themes. You should have a new Preference value in the
Attribute Type drop down on this page. Add rows to the User Attribute Based Theme Assignments grid for each of the existing themes and ensure to set
the Attribute Value and Theme Value to the same value for each row.
The system will loop over the rows in this grid at sign in time and it will call the validateValue method of the custom User Attribute Application Class to determine if the particular theme needs to be assigned to the user’s session.
When a user selects a theme in My Preferences, the selected theme should get applied the next time the user logs into the system.
Leave a comment
Your email address will not be published. Required fields are marked *