Reputation: 909
I've got a field in my DAC where I want to put a selector that looks up the SalesPersons. I know how to do this:
[PXSelector(typeof(SalesPerson.salesPersonCD)
,typeof(SalesPerson.salesPersonCD)
,typeof(SalesPerson.descr))]
My problem is that I want to filter this selector based on the first three characters of the SalesPerson CD, i.e., StartsWith "SSR" or something similar. I know you can use BQL in a selector using the Search<> command, and I know how to set up a constant class, but I'm not sure of the syntax to filter by beginning characters.
Upvotes: 2
Views: 810
Reputation: 3783
Short of creating a custom BQL operator, you can achieve "Starts with" by using the LIKE operator, with the % wildcard at the end. The BQL field you're filtering on could be a DAC property with custom code in the get accessor, which takes your user-entered field and adds the wildcard character at the end, like that:
public abstract class myFieldWildcard : PX.Data.IBqlField { };
[PXString(30, IsUnicode = true)]
public virtual String MyFieldWildcard
{
[PXDependsOnFields(typeof(myField)]
get
{
return MyField + PXDatabase.Provider.SqlDialect.WildcardAnything;
}
}
You'll then be able to use that field as part of your PXSelector
attribute:
[PXSelector(typeof(Search<SomeTable.someField, Where<SomeTable.someField,Like<Current<MyFilter.myFieldWildcard>>>>))]
Upvotes: 5