IDEMPIERE-3485 Report/Process: Unique constraint exception after save parameter

This commit is contained in:
Heng Sin Low 2017-09-13 16:35:03 +08:00
parent d4765a29e4
commit 731ae053a8
2 changed files with 16 additions and 1 deletions

View File

@ -232,4 +232,19 @@ public class MPInstancePara extends X_AD_PInstance_Para
} }
return -1; return -1;
} }
/**
* Get existing AD_PInstance_Para record or create a new one if not found
* @param ctx
* @param AD_PInstance_ID
* @param SeqNo
*/
public static MPInstancePara getOrCreate(Properties ctx, int AD_PInstance_ID, int SeqNo)
{
Query query = new Query(ctx, Table_Name, "AD_PInstance_ID=? AND SeqNo=?", null);
MPInstancePara para = query.setParameters(AD_PInstance_ID, SeqNo).first();
if (para == null)
para = new MPInstancePara(ctx, AD_PInstance_ID, SeqNo);
return para;
}
} // MPInstance_Para } // MPInstance_Para

View File

@ -520,7 +520,7 @@ public class ProcessParameterPanel extends Panel implements
result2 = editor2.getValue(); result2 = editor2.getValue();
// Create Parameter // Create Parameter
MPInstancePara para = new MPInstancePara(Env.getCtx(), MPInstancePara para = MPInstancePara.getOrCreate(Env.getCtx(),
m_processInfo.getAD_PInstance_ID(), i); m_processInfo.getAD_PInstance_ID(), i);
GridField mField = (GridField) m_mFields.get(i); GridField mField = (GridField) m_mFields.get(i);
para.setParameterName(mField.getColumnName()); para.setParameterName(mField.getColumnName());