From 70bb9041d29b21e7e1f38a1f1b97fd12572dc7b0 Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Sat, 8 Feb 2020 13:16:03 +0100 Subject: [PATCH] IDEMPIERE-4169 Unresolved elements of 'Record_ID' in AttachmentElementHandler --- .../src/org/adempiere/pipo2/PoFiller.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/org.adempiere.pipo/src/org/adempiere/pipo2/PoFiller.java b/org.adempiere.pipo/src/org/adempiere/pipo2/PoFiller.java index db248bc2f0..3688c9e120 100644 --- a/org.adempiere.pipo/src/org/adempiere/pipo2/PoFiller.java +++ b/org.adempiere.pipo/src/org/adempiere/pipo2/PoFiller.java @@ -189,10 +189,20 @@ public class PoFiller{ foreignTable = MTable.get(Env.getCtx(), refTableName); } else { if ("Record_ID".equalsIgnoreCase(columnName)) { - // special case - get the foreign table using column AD_Table_ID - int idxTableID = po.get_ColumnIndex("AD_Table_ID"); - if (idxTableID >= 0) { - int tableID = po.get_ValueAsInt(idxTableID); + // special case - get the foreign table using AD_Table_ID + int tableID = 0; + try { + // try it first from the XML element, is possible that the table is still not filled in the po object + tableID = Integer.parseInt(e.parent.properties.get("AD_Table_ID").contents.toString()); + } catch (Exception e1) {} + if (tableID == 0) { + // XML didn't work, try the po object + int idxTableID = po.get_ColumnIndex("AD_Table_ID"); + if (idxTableID >= 0) { + tableID = po.get_ValueAsInt(idxTableID); + } + } + if (tableID > 0) { foreignTable = MTable.get(Env.getCtx(), tableID); refTableName = foreignTable.getTableName(); }