Maximo

Maximo

Come for answers, stay for best practices. All we're missing is you.

 View Only

Maximo Numerical Field Formatting

  • 1.  Maximo Numerical Field Formatting

    Posted 12 hours ago

    Good morning community...

    As I have recently had to change the formatting on numerical fields to remove the thousand separator (comma), I thought I would post my solution here. Firstly to find out if there may be a better or more elegant way to achieve this, and secondly, as it may be of use to someone else who is trying to do the same thing?

    In Maximo (v7.6), the default for displaying integer based numbers, is to use a comma for thousand separators. Searching the internet for a way to remove these commas, results in the following common options:

     

    1. Change the data format to ALN

    2. Change the localisation settings

    3. Implement an automation script

     

    Whilst option 1 is the easiest to implement, if we changed the data type, it could result in a nonnumeric value ending up in this field at some point. This could have further implications if other processes relied on this value being numeric. Option 2 is not really an option (although hinted at in a technote) as this could have other side effects, detrimental to the users' expectations. Option 3, I couldn't find a suitable way to implement this without using a nonpersistent ALN field, as Maximo will obviously format an integer field according to it's rules.

     

    The solution I came up with was to modify the textbox.jsp file (located at: maximo.ear/maximouiweb.war/webclient/components/textbox.jsp). Make sure that you take a copy/backup of the file first! I opted for doing it this way because it is only modifying what it displayed on the screen, and not changing data types or the underlying data. This change can also be made (or undone) without having to restart the Maximo instances, if that is important to you…

     

    Find the following text (starts around line 559 in our file):

     

    String ariaLabel = component.getProperty("arialabel");

    if(componentVisible && component.getProperty("visible").equals("true"))

    {

    %><input datatype="<%=dataType%>" id="<%=id%>" <%=ariaString%> <%=staticname%><%=ariaRole%><%=ariaLabelledBy%> class="fld <%=cssclass%> <%=exceptionClass%>" <%=exc%><%

    %> <%=stopAlign%> <%=min%> <%=max%> ctype="textbox" <%=bidiTagAttributes[0]%> <%=numericAttribute%><%

    %> <%=linkBackId%> <%=liClick%> <%=defaultButton%> <%=hasValue%> <%=num%> <%=maxlength%><%

    %> style="<%=numericStyle%>;<%=width%>;" <%=isdatefield %> <%=ontr%> <%=dojoTypeInput%> <%if(!isReadOnly){%><%=asyncStr%> <%=asyncevents%><%}%><%

    %> <%=stopUserEdit%> <%=tabindex%> <%=readOnly%> type="<%=inputType%>" <%=title%> <%if(hidelabel){ title=component.getProperty("title");%> placeholder="<%=title%>" promptValue="<%=title%>" aria-label="<%=title%>"<%}else if(ariaLabel.length()>0){%> aria-label="<%=ariaLabel%>"<%}

    if(isDate)

    {

    %> value=""<%

    }

    else

    {

    %> value="<%=value%>"<%if(!isReadOnly){%> ov="<%=value%>"<%}%><%

    }

    if(wcs.isAutomationOn())

    {

    %> automationid="<%=component.getId()%>"<%

    }

    if(!control.isOnTableFilterRow())

    {

    %> work="1"<%

    }

    if(fieldInfo!=null && !isReadOnly)

    {

    %> fldInfo='<%=WebClientRuntime.makesafevalue(fieldInfo.serialize())%>'<%

    }

    %>/><%=helpImage%><%

    if(isDate)

    {

    %> <script type="text/javascript">

    require(["ibm/tivoli/mbs/html"], function(html){

    formatCalendar('<%=id%>',html.decodeEntities('<%=value%>'));

    });

    </script>

    <% }

    }

     

    And change it as follows:

     

    String ariaLabel = component.getProperty("arialabel");

    if(componentVisible && component.getProperty("visible").equals("true"))

    {

    %><input datatype="<%=dataType%>" id="<%=id%>" <%=ariaString%> <%=staticname%><%=ariaRole%><%=ariaLabelledBy%> class="fld <%=cssclass%> <%=exceptionClass%>" <%=exc%><%

    %> <%=stopAlign%> <%=min%> <%=max%> ctype="textbox" <%=bidiTagAttributes[0]%> <%=numericAttribute%><%

    %> <%=linkBackId%> <%=liClick%> <%=defaultButton%> <%=hasValue%> <%=num%> <%=maxlength%><%

    %> style="<%=numericStyle%>;<%=width%>;" <%=isdatefield %> <%=ontr%> <%=dojoTypeInput%> <%if(!isReadOnly){%><%=asyncStr%> <%=asyncevents%><%}%><%

    %> <%=stopUserEdit%> <%=tabindex%> <%=readOnly%> type="<%=inputType%>" <%=title%> <%if(hidelabel){ title=component.getProperty("title");%> placeholder="<%=title%>" promptValue="<%=title%>" aria-label="<%=title%>"<%}else if(ariaLabel.length()>0){%> aria-label="<%=ariaLabel%>"<%}

    if(isDate)

    {

    %> value=""<%

    }

    else

    {

    // Code removes commas from being displayed in numeric values and 

    // removes everything after 2 decimal places.

    try {

    if (isNumeric && dataType == 9) 

    {

    String dispData = value;

    dispData = dispData.replace(",","");

     

    int index = dispData.indexOf('.');

    if (index >= 0) {

    dispData = dispData.substring(0, index+3);

    }

    %> value="<%=dispData%>"<%if(!isReadOnly){%> ov="<%=dispData%>"<%}%><%

    }

    else

    {

    %> value="<%=value%>"<%if(!isReadOnly){%> ov="<%=value%>"<%}%><%

    }

    }

    catch (Exception e) {

    %> value="<%=value%>"<%if(!isReadOnly){%> ov="<%=value%>"<%}%><%

    }

    }

    if(wcs.isAutomationOn())

    {

    %> automationid="<%=component.getId()%>"<%

    }

    if(!control.isOnTableFilterRow())

    {

    %> work="1"<%

    }

    if(fieldInfo!=null && !isReadOnly)

    {

    %> fldInfo='<%=WebClientRuntime.makesafevalue(fieldInfo.serialize())%>'<%

    }

    %>/><%=helpImage%><%

    if(isDate)

    {

    %> <script type="text/javascript">

    require(["ibm/tivoli/mbs/html"], function(html){

    formatCalendar('<%=id%>',html.decodeEntities('<%=value%>'));

    });

    </script>

    <% }

    }

     

    Once the file has been saved, you should be able to reload the application (e.g. work order tracking) and see that the formatting of the fields has been changed.

     

    Before textbox.jsp modification:

     

    After textbox.jsp modification:


    Note: This will affect all numeric fields where the dataType property is set to 9. In the above modification, you can see that if the formatting process fails, it will default to using the original Maximo code line to display the value…



    ------------------------------
    Chris Price
    Solutions Architect
    South East Water
    Snodland
    ------------------------------