I have created a line level field in AP303000 form and I need to have Attribute ID selector
namespace MidayaCustomizations
{
public class APTranExt : PXCacheExtension<PX.Objects.AP.APTran>
{
#region UsrAttributeSelection
PXDBString(250)]
PXUIField(DisplayName = "Attribute ID")]
PXSelector(typeof(Search<CSAttributeDetail.attributeID,Where<CSAttributeDetail.attributeID, Equal<CSAttribute.attributeID>>>),
typeof(CSAttributeDetail.attributeID))]
public virtual string UsrAttributeSelection { get; set; }
public abstract class usrAttributeSelection : PX.Data.BQL.BqlString.Field<usrAttributeSelection> { }
#endregion
#region UsrAttributeValues
PXDBString(250)]
PXUIField(DisplayName = "Attribute Values")]
public virtual string UsrAttributeValues { get; set; }
public abstract class usrAttributeValues : PX.Data.BQL.BqlString.Field<usrAttributeValues> { }
#endregion
}
}
And I need to get the Attribute ID from that field and in the UsrAttributeValues field, the values from that particular attribute should be populated (eg- Attribute ID “CSS” is a dropdown field and in UsrAttributeValues field these list of values should be available to be selected).
protected void APTran_UsrAttributeSelection_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated InvokeBaseHandler)
{
InvokeBaseHandler?.Invoke(cache, e);
APTran row = (APTran)e.Row;
if (row == null) return;
var rowExt = PXCache<APTran>.GetExtension<APTranExt>(row);
List<string> allowedValues = new List<string>();
List<string> allowedLabels = new List<string>();
if (rowExt != null)
{
foreach (CSAttributeDetail objCSAttributeDetail in PXSelect<CSAttributeDetail,
Where<CSAttributeDetail.attributeID, Equal<Required<APTranExt.usrAttributeSelection>>>>.Select(Base, rowExt.UsrAttributeSelection))
{
allowedValues.Add(objCSAttributeDetail.ValueID);
allowedLabels.Add(objCSAttributeDetail.Description);
}
e.ReturnState = PXStringState.CreateInstance(e.ReturnState, 10, true, typeof(APTranExt.usrAttributeValues).Name, false, -1, string.Empty, allowedValues.ToArray(), allowedLabels.ToArray(), false, null);
}
}
Currently trying to use a field updated event, but I am facing errors, any help would be appreciated.