Service Portal add current user's name i.e. "Hi Joe, How Can We Help?"

reginabautista
Kilo Sage

Hi guys how can we add the current user's name to the "How Can We Help?" message on the main SP page? Please refer to attached screenshot. Thanks - Regina

1 ACCEPTED SOLUTION

For the newly cloned widget...



Just write the below line in the Server part:



data.user = gs.getUserName();



View solution in original post

21 REPLIES 21

Any help on how I can get this to use the first name from the sys_user table?


Hi Allison,



Try this in your new widget and let me know if it works for you:



Try this in your 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;


}


}



Your HTML Template should look like this:


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


  <div class="wrapper-xl">


<h1 class="text-center text-3x m-b-lg sp-tagline-color" ng-bind="data.greeting"></h1>


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


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


  </div>


</div>



Your Server Script should look like this:


data.typeAheadSearch = $sp.getWidget('typeahead-search', options.typeahead_search);


That's great, I really like this Daniel. Thanks


@danielbrandao 

How would you change the color of the font to white?

 

Your HTML Template should look like this:

 

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

 

  <div class="wrapper-xl">

 

<h1 class="text-center text-3x m-b-lg sp-tagline-color" ng-bind="data.greeting"></h1>

 

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

 

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

 

  </div>

 

</div>

 

For the newly cloned widget...



Just write the below line in the Server part:



data.user = gs.getUserName();