Wednesday, January 29, 2014

Show the Username and Default Insert Site in the Maximo header

Goal: 
To show the currently logged-in user and his Default Insert site in the header of the Maximo 7.5.0.5 application 

Problem:
When working in some Maximo applications (e.g. workorder and locations) in a multi-site environment the user must have the Default Insert site set to the site he wants to insert a new record for.

This information is displayed in Maximo through a menu, but the user will first have to open it. It would be nice to always show the user his Default Insert Site.

Solution:
Show the Default Insert site of the user in the header of Maximo.

In the header there is room for some information, like shown in the picture below:





Step 1 - Locate the file

In order to show information in this part of Maximo we need to modify the titlebar.jsp

This file is located in \IBM\SMP\maximo\applications\maximo\maximouiweb\webmodule\webclient\components

This is regardless of what skin you use.

Make a copy of titlebar.jsp as a backup in this directory. 


Modify the titlebar.jsp

After the line  (line 20):


String userFullName = control.getWebClientSession().getUserInfo().getDisplayName();

Enter the following lines:

String defSite= "";

try
{
  defSite= control.getWebClientSession().getUserInfo().getInsertSite();
}
  catch(Exception ex)
{
  defSite="Unknown";
}


In essention I create a variable that is empty. I try to get the user his InsertSite and put that in the variable. If no InsertSite exists I fill the variable with the text "Unknown"

Here a picture of the first change:





Then find the following block of code(original line number 130) :

<td style="vertical-align:<%if(useHomeButton){%>middle<%}else{%>top<%}%>;white-space: nowrap;">
    <span id="txtappname" class="<%if(useHomeButton)%>homeButton<%}%>txtappname">&nbsp;
<%=apptitle%>
    </span>
</td>


Enter the following code after the code found above:

<td width="290"nowrap style="vertical-align:top" align="right">
    <span class="txtappname">&nbsp;
        <font color="C0C0C0">User:        </font><%=userFullName%> &nbsp; &nbsp;
        <font color="C0C0C0">Insert Site: </font><%=defSite%>
    </span>
</td>

Here I add the code to set the new variable on the screen, I also show the userFullName variable here in order to show the user his full name.

Here is a picture of the modification:




Next rebuild the maximo.ear and redeploy the Maximo application.
After loggin in to Maximo you should see the username and default insert site in the header. Could be that your browser has cached some headerinformation, always try a hard refresh (CTRL + F5) if nothing shows up.

It should end up looking like this (I changed the name for privacy reasons):



It looks like itis show twice, but that is only on the startscreen. When opening the Workorders application for example you will see the second mention of the name is useful:





GNZ.