Skip to content

Instantly share code, notes, and snippets.

@smarenich
Created August 15, 2016 09:56
Show Gist options
  • Save smarenich/0e0985f974d50afe91c4f2661586548f to your computer and use it in GitHub Desktop.
Save smarenich/0e0985f974d50afe91c4f2661586548f to your computer and use it in GitHub Desktop.
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