IDEMPIERE-4215 Allow subtype tables in context variables
This commit is contained in:
parent
170739bf6f
commit
de41df7752
|
@ -1674,14 +1674,25 @@ public final class Env
|
|||
else
|
||||
tableName = foreignTable;
|
||||
MTable table = MTable.get(ctx, tableName);
|
||||
if (table != null && (tableName.equalsIgnoreCase(foreignTable) || tableName.equalsIgnoreCase(po.get_TableName()))) {
|
||||
String keyCol = tableName + "_ID";
|
||||
boolean isSubTypeTable = false;
|
||||
if (! Util.isEmpty(foreignTable) && ! tableName.equalsIgnoreCase(foreignTable)) {
|
||||
// verify if is a subtype table
|
||||
if ( table.getKeyColumns() != null
|
||||
&& table.getKeyColumns().length == 1
|
||||
&& table.getKeyColumns()[0].equals(foreignTable + "_ID")) {
|
||||
isSubTypeTable = true;
|
||||
keyCol = foreignTable + "_ID";
|
||||
}
|
||||
}
|
||||
if (table != null && (isSubTypeTable || tableName.equalsIgnoreCase(foreignTable) || tableName.equalsIgnoreCase(po.get_TableName()))) {
|
||||
String columnName = tblIndex > 0 ? format.substring(tblIndex + 1) : format;
|
||||
MColumn column = table.getColumn(columnName);
|
||||
if (column != null) {
|
||||
if (column.isSecure()) {
|
||||
outStr.append("********");
|
||||
} else {
|
||||
String value = DB.getSQLValueString(trxName,"SELECT " + columnName + " FROM " + tableName + " WHERE " + tableName + "_ID = ?", (Integer)v);
|
||||
String value = DB.getSQLValueString(trxName,"SELECT " + columnName + " FROM " + tableName + " WHERE " + keyCol + "=?", (Integer)v);
|
||||
if (value != null)
|
||||
outStr.append(value);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue