'Customer and Contact columns in PXCustomSelectorAttribute
I have created a custom selector attribute, that filters what customers will appear in the popup box based on the user's ID.
But I have run into the problem that I can't seem to customize it like a normal selector ie:
[PXSelector(typeof(Search2<InventoryItem.inventoryID, LeftJoin<INItemQtyCost, On<InventoryItem.inventoryID, Equal<INItemQtyCost.inventoryID>>>>),
typeof(InventoryItem.inventoryCD), typeof(InventoryItem.descr), typeof(INItemQtyCost.qtyAvail)
SubstituteKey = typeof(InventoryItem.inventoryCD),
Filterable = true)]
And can only use my custom selector attribute like this:
[SalesRepCustomer]
The constructor for the PXCustomSelectorAttribute is as follows:
public SalesRepCustomer() : base(typeof(Customer.bAccountID))
{
this.DescriptionField = typeof(Customer.acctName);
this.SubstituteKey = typeof(Customer.acctCD);
}
Is there a way to use the search2<> and so on in a PXCustomSelectorAttribute?
Solution 1:[1]
The whole point of a PXCustomSelectorAttribute is to override the "GetItems" method where you define the search function used to return records:
From https://asiablog.acumatica.com/2016/09/custom-selector-attribute.html
public class CustomerPriceClassAttribute : PXCustomSelectorAttribute
{
public CustomerPriceClassAttribute()
: base(typeof(ARPriceClass.priceClassID))
{
this.DescriptionField = typeof(ARPriceClass.description);
}
protected virtual IEnumerable GetRecords()
{
foreach (ARPriceClass pc in PXSelect<ARPriceClass>.Select(this._Graph))
{
yield return pc;
}
}
}
You can use PXSelectJoin or other PXSelect classes if you want.
Solution 2:[2]
Utilization of the PXSelectorAttribute
public class SalesRepCustomer : PXSelectorAttribute
{
public SalesRepCustomer() : base(typeof(Search<Customer.bAccountID>))
{
}
}
Usage would be as follows :
public class BatchExtension : PXCacheExtension<Batch>
{
public abstract class usrSalesRepCustomerID : BqlInt.Field<usrSalesRepCustomerID>
{
}
[SalesRepCustomer(SubstituteKey = typeof(Customer.acctName), DescriptionField = typeof(Customer.legalName))]
public int? UsrSalesRepCustomerID
{
get; set;
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kyle Vanderstoep |
| Solution 2 | Joshua Van Hoesen |
