want to populate the logged in user on the " how can we help ? " message

tGhadage
Tera Contributor

Hi Guys, 

 

I want to populate the logged in username to " How can we help? " Message  below is my code please help with this. 

 

Html script : 

<div id="homepage-search" class="hidden-xs wrapper-xl">

 


<div class="wrapper-xl">


<h1 class="text-center text-4x m-b-lg sp-tagline-color">Hi {{data.user}}, Welcome to Portal.</h1>


<h4 ng-if="options.short_description" class="text-center m-b-lg sp-tagline-color" ng-bind="options.short_description"></h4>


<sp-widget widget="data.typeAheadSearch" />


</div>


</div> 

 

Client script :  

function() {
//Add greeting based on time of day and add user's first name
var c = this;
var today = new Date()
var curHr = today.getHours()
if (curHr < 12) {
c.data.greeting = 'Good morning ' + scope.user.first_name;
} else if (curHr < 18) {
c.data.greeting = 'Good afternoon ' + scope.user.first_name;
} else {
c.data.greeting = 'Good evening ' + scope.user.first_name;
}

 

Server script : 

 

(function() {
// Collect the User Info to Display Users First Name


data.sysUserID = gs.getUserID();


if (!data.sysUserID)


data.sysUserID = gs.getUser().getID();


var sysUserGR = new GlideRecord("sys_user");


data.userExists = sysUserGR.get(data.sysUserID);

 

if (data.userExists) {


data.name = sysUserGR.getValue("first_name");


} else {


data.name = "User";


}


})();

attached a screenshot for your reference - 

 

Screenshot (186).png

it's not working with this code, I missed something. Please help!!

1 ACCEPTED SOLUTION

Hi @tGhadage ,

Please update your HTML code as below - 

HTML -

<div id="homepage-search" class="hidden-xs wrapper-xl">
<div class="wrapper-xl">
<h1 class="text-center text-4x m-b-lg sp-tagline-color">Hi {{c.data.greeting}}, Welcome to Portal.</h1>
<h4 ng-if="options.short_description" class="text-center m-b-lg sp-tagline-color" ng-bind="options.short_description"></h4>
<sp-widget widget="data.typeAheadSearch" />
</div>
</div> 

 

Please mark my answer as Helpful/Accept as Solution if it resolved your issue.

View solution in original post

6 REPLIES 6

Hi @Anirudh Pathak , 

 

Thanks man, its working now.

figured out the search bar part no issues its just the greeting message now.