Keep it Personal – Show them their own name!

One very simple way to add some personalization to a CMS site is to include the name of the person visiting it. If you just want to display the current user and/or do a query against a specific name file, this code is great to get you started:

<!–Do a look-up and find the First Name of the current user –>
var name = gs.getUser().getFirstName()
if(name == ''){
<!–If there is no value for First Name, then query the sys_user table and get the user_name value –>
var usr = new GlideRecord('sys_user');
name = usr.user_name.getDisplayValue()
if(name == ''){
name ="empty";
<!– Wrap the actual value however you choose (i.e. H3 or p tags) –>
<div class="user_name">

Leave a Reply