One More Example Of Selectors
Hello everybody,
today I want to present one more example of selectors, but the one, that has multiple fields in it.
Consider following code:
using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using PX.Data; using PX.Objects.CS; using PX.Objects.CT; using PX.Objects.DR; namespace MyBlog { public class DeliverySelectorAttribute : PXCustomSelectorAttribute { public DeliverySelectorAttribute(Type selectorField, params System.Type[] fieldList) : base(selectorField, fieldList) { } public override void FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e) { } string[] validIds = new[] { "FEDEX 1 CLS", "OLX PR EX", "AMAZON PRIOR" }; protected virtual IEnumerable GetRecords() { var selectedValues = PXSelect<Carrier>.Select(this._Graph); var result = new List<Carrier>(); foreach (PXResult<Carrier> selectedValue in selectedValues) { if (validIds.Contains(selectedValue.GetItem<Carrier>().CarrierID)) { result.Add(selectedValue); } } return result; } } }
If to compare it with previous selector code it have option of choice of multiple columns instead of showing only one columng.
Later in your program you can reuse this selector like this:
Snippet
[DeliverySelector(typeof(Carrier.carrierID), new System.Type[] { typeof(Carrier.carrierID), typeof(Carrier.description),
typeof(Carrier.isCommonCarrier), typeof(Carrier.confirmationRequired), typeof(Carrier.packageRequired) },
CacheGlobal = true, DescriptionField = typeof(Carrier.description))]
New selector format allows you to display any kind of special selector fields.
Ready to take your Acumatica development to the next level? The example above showcases how you can create advanced, multi-field selectors to enhance your application's functionality. But why stop there? If you have a unique business need or a specific customization in mind, we’re here to help! Leave a customization request today, and let’s build a solution tailored to your requirements. Your vision, our expertise—let’s make it happen!