Adding an Associate's Name to the Web Office Header

Admin: Web Office Admin
Page: Code Customization > Javascript Insertions
URL: {client_ID}.admin.directscale.com/#/Insertions

Using the JavaScript Insertions page, you can make it, so an associate's name appears next to their profile image in the Web Office header.

Before

After



Adding an Insertion

  1. In the JavaScript Insertions page, click + ADD INSERTION.
  2. Select Custom Script from the Insertion Type menu.
  3. Enter a sort Name.
  4. In the JavaScript Code Editor, paste the following code:
try {
  
 	// This makes the userService collection available for the HTML element
  angular.element(document).injector().invoke(function ($rootScope,UserService) {
    $(document).ready(function () {
      
      // Begin Function
      function SetUserName() {
        setTimeout(function () {
          
          // Get Web Office User profile image menu class
          var element = $('.ds_Avatar-menu');
          
          // Create HTML with the user's first and last name text
					var logoHtml ='<span class="c-white m-r-20">'+UserService.LoggedInUser.FirstName+" "+UserService.LoggedInUser.LastName+'</span>';
          console.log(logoHtml)	
          
          // Put them together
          element.prepend(logoHtml);
        }, 1000);
      } // End function
      
      SetUserName();
      
      $rootScope.$on('$stateChangeSuccess', function () {
        SetUserName();
      });
    });
  });
}
catch (err) {
  console.log(err, 'Add associate name to the header -- Error');
}
  1. Enable the Published toggle to activate the script after saving.
  2. Customize who can further see their user name with Multi-faceted Configuration, if needed.
  3. Click SAVE.