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 –>
<g:evaluate>
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');
usr.get(gs.getUserID());
name = usr.user_name.getDisplayValue()
}
if(name == ''){
name ="empty";
}
</g:evaluate>
<!– Wrap the actual value however you choose (i.e. H3 or p tags) –>
<div class="user_name">
${name}
</div>

Author

With over a decade of experience, I have managed online marketing for a wide range of industries including biotech, high-tech, financial, higher education, non-profit, manufacturing, hardware providers, and startups. My specialty is helping business make the right turn with their online efforts focusing on lead generation and analytics.

Leave a Reply