Usually Acumatica Drop-Down controls have fixed lists of values. Of course you can use PXStringListAttribute.SetList<…>(…) method do change list of values dynamically, but how to make it more handy.
The way I recommend you is to create an attribute that can encapsulate all the field related logic, so to use it you can just put the attribute on the proper place.
So the plan:
- Create an attribute that will be inherited from PXStringList and provide the values
- Create IPrefetchable class that can be automatically load all possible list from DB and cache it. In the same time Acumatica will auto-reset when the linked table is changed. This is really great performance optimization. Read more about caching data with database slots here.
- Use PXDatabase.GetSlot to retrieve the data from memory. If data is not yet cached or changed Acumatica platform will automatically will call Prefertch method to refresh data.
- Subscribe to RowSelected event and adjust the list using SetList method.
- Apply attribute on the field in the DAC
Please see the full example here:
Really hope it helps and have a nice development!