Hello @SadokHanini
To load the drop-down values dynamically, then we need to use fieldselecting event to load the values dynamically. Please find the example below.
protected virtual void SOOrder_UsrKNOrderReturnCodes_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e)
{
SOOrder row = e.Row as SOOrder;
if (row != null)
{
List<string> allowedValues = new List<string>();
foreach (KNAMICodes objAMICodes in PXSelect<KNAMICodes, Where<KNAMICodes.codeType, Equal<AMIConstants.ReturnCodes>,
And<KNAMICodes.isActive, Equal<True>>>>.Select(Base))
{
allowedValues.Add(objAMICodes.Codecd);
}
e.ReturnState = PXStringState.CreateInstance(e.ReturnState, 10, true, typeof(KNAMICodes.codecd).Name, false, -1, string.Empty, allowedValues.ToArray(), allowedValues.ToArray(), false, null);
((PXStringState)e.ReturnState).MultiSelect = false;
}
}
I hope this will help you!!