IDEMPIERE-4641 AD_ProcessPara.DisplayLogic is not accepting @Value_ID.ForeignColumn@ notation (#520)

This commit is contained in:
Carlos Ruiz 2021-01-12 14:33:48 +01:00 committed by GitHub
parent 402300a53e
commit a1f39f9506
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 10 deletions

View File

@ -1243,23 +1243,34 @@ public class GridField
} }
value = Env.getContext (ctx, m_vo.WindowNo, m_vo.TabNo, variableName, tabOnly, true); value = Env.getContext (ctx, m_vo.WindowNo, m_vo.TabNo, variableName, tabOnly, true);
} }
if (!Util.isEmpty(value) && !Util.isEmpty(foreignColumn) && variableName.endsWith("_ID") if (!Util.isEmpty(value) && !Util.isEmpty(foreignColumn) && variableName.endsWith("_ID")) {
&& getGridTab() != null) {
String refValue = "";
int id = 0; int id = 0;
try { try {
id = Integer.parseInt(value); id = Integer.parseInt(value);
} catch (Exception e){} } catch (Exception e){}
if (id > 0) { if (id > 0) {
MColumn column = MColumn.get(ctx, getGridTab().getTableName(), variableName); String refValue = "";
if (column != null) { if (getGridTab() != null) {
String foreignTable = column.getReferenceTableName(); MColumn column = MColumn.get(ctx, getGridTab().getTableName(), variableName);
refValue = DB.getSQLValueString(null, if (column != null) {
"SELECT " + foreignColumn + " FROM " + foreignTable + " WHERE " String foreignTable = column.getReferenceTableName();
+ foreignTable + "_ID = ?", id); refValue = DB.getSQLValueString(null,
"SELECT " + foreignColumn + " FROM " + foreignTable + " WHERE "
+ foreignTable + "_ID = ?", id);
}
return refValue;
} else {
// no GridTab - maybe coming from process parameter, try tableName from columnName
String foreignTable = variableName.substring(0, variableName.length()-3);
MTable table = MTable.get(ctx, foreignTable);
if (table != null) {
refValue = DB.getSQLValueString(null,
"SELECT " + foreignColumn + " FROM " + foreignTable + " WHERE "
+ foreignTable + "_ID = ?", id);
return refValue;
}
} }
} }
return refValue;
} }
return value; return value;
} // get_ValueAsString } // get_ValueAsString