On Start Center Result Set Portlets, expressions for color codes do not work as intended for numeric fields, i.e. integer or decimal data type. The root cause of this issue is the thousands separator (dot or comma) for the numeric fields. The expression value for comparison is alphanumeric. Changing the field type to alphanumeric is not a solution since it does string comparison, i.e. compares hexadecimal values.
Example:
Assume we have two display options for an integer field such as;
If field value < 1000, then color code = red
If field value >= 1000, then color code = green
When the field value is 300, the system colors the row in red as expected. But when the field value is 3000, the system colors the row in red again, although it is expected to be green.
Issue and Root Cause:
The comparison is realized in resultsetportlet.jsp which is located under maximo.ear/maximouiweb.war/webclient/components folder. The function responsible for the confusion is compareValues() method of psdi.webclient.controls.ResultSetPortlet bean class used in resultsetportlet.jsp. The following line should be searched in resultsetportlet.jsp.
style = portletControl.compareValues(conditionValue);
Later, we search for compareValues() method within psdi.webclient.controls.ResultSetPortlet bean class. The code piece below is the root cause for format confusion. psdi.mbo.MboValueData.getData() method fetches the data as string which causes an incorrect conversion.
String compareTo = mvd.getData();
...
double d1 = MXFormat.stringToDouble(compareTo);
double d2 = MXFormat.stringToDouble(value);
Resolution:
The custom class below (com.custom.beans.resultset.CustomResultSetPortlet) can be applied as a solution which will replace the psdi.webclient.controls.ResultSetPortlet.compareValues() method. The main difference is emphasized in bold font which basically fetches the data in its own type (integer, double, float, long) instead of fetching it as string. The rest of the logic is same as the original class.
package com.custom.beans.resultset;
import java.rmi.RemoteException;
import java.util.Date;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import psdi.app.rsconfig.RSConfigSetRemote;
import psdi.mbo.MboValueData;
import psdi.server.MXServer;
import psdi.util.MXException;
import psdi.util.MXFormat;
import psdi.util.MXSystemException;
import psdi.util.logging.MXLogger;
import psdi.util.logging.MXLoggerFactory;
import psdi.webclient.controls.ResultSetPortlet;
public class CustomResultSetPortlet {
private static HashSet expressionConditions;
static MXLogger myLogger = MXLoggerFactory.getLogger("maximo.application.STARTCNTR");
private static ResultSetPortlet portletControl;
public static String compareValues(MboValueData mvd, ResultSetPortlet rsp) {
boolean isConditionTrue = false;
int intType = mvd.getTypeAsInt();
String compareTo = mvd.getData();
String style = "";
try {
if (compareTo.equals("")) {
return "";
}
expressionConditions = getConditions(rsp);
Iterator expressions = expressionConditions.iterator();
while (expressions.hasNext()) {
Hashtable entry = (Hashtable) expressions.next();
String expression = (String) entry.get("expression");
String value = getReplacementValue((String) entry.get("expvalue"), rsp);
String color = entry.get("color").toString();
double d1, d2;
switch (intType) {
case 7:
d1 = (double) mvd.getDataAsInt();
d2 = MXFormat.stringToDouble(value);
isConditionTrue = compareDoubles(expression, d1, d2);
break;
case 8:
d1 = (double) mvd.getDataAsFloat();
d2 = MXFormat.stringToDouble(value);
isConditionTrue = compareDoubles(expression, d1, d2);
break;
case 9:
case 10:
case 11:
d1 = mvd.getDataAsDouble();
d2 = MXFormat.stringToDouble(value);
isConditionTrue = compareDoubles(expression, d1, d2);
break;
case 6:
case 19:
d1 = (double) mvd.getDataAsLong();
d2 = MXFormat.stringToDouble(value);
isConditionTrue = compareDoubles(expression, d1, d2);
break;
case 12:
String dataYorN = MXFormat.convertToStoreYNValue(compareTo,
rsp.getWebClientSession().getUserInfo().getLocale());
String customerYorN = MXFormat.convertToStoreYNValue(value,
rsp.getWebClientSession().getUserInfo().getLocale());
if (express