Instantly share code, notes, and snippets.

Embed
What would you like to do?
internal class CompanySelectorAttribute : PXCustomSelectorAttribute
{
public CompanySelectorAttribute()
: base(typeof(UPCompany.companyID))
{ }
protected virtual IEnumerable GetRecords()
{
return PXCompanyHelper.SelectCompanies();
}
public override void DescriptionFieldSelecting(PXCache sender, PXFieldSelectingEventArgs e, string alias)
{
if (e.Row == null || (sender.GetValue(e.Row, _FieldOrdinal) == null)) base.DescriptionFieldSelecting(sender, e, alias);
else
{
UPCompany item = null;
Object value = sender.GetValue(e.Row, _FieldOrdinal);
Int32 key = (Int32)value;
foreach (UPCompany info in PXCompanyHelper.SelectCompanies())
{
if (info.CompanyID == key)
{
item = info;
break;
}
}
if(item != null) e.ReturnValue = sender.Graph.Caches[_Type].GetValue(item, _DescriptionField.Name);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment