Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filtering Dropdown Selection List Prior To Searching #24

Open
padenallen15 opened this issue Apr 5, 2024 · 3 comments
Open

Filtering Dropdown Selection List Prior To Searching #24

padenallen15 opened this issue Apr 5, 2024 · 3 comments

Comments

@padenallen15
Copy link

Hey Mark,

Currently, the filter field seems to primarily function as a search tool, which is useful, but I require pre-typing filtration.

Let's say in the related table, we have columns named 'Company Name' and 'Status'. Ideally, before a user starts typing, the dropdown list should already be filtered to display only items where the status is 'Active'.

For instance, let's consider a scenario with three records in the related table:

Company Name | Status
Amazon | Active
Google | Active
Apple | Inactive

If a user attempts to search for 'Apple', they shouldn't retrieve any results, and it shouldn't appear in the dropdown because it's marked as Inactive.

Deleting inactive items from the related table isn't feasible since we need to preserve historical data in archived records. Thus, when an item becomes 'Inactive', users shouldn't be able to select it in future records, but any archived record retaining that value should remain unchanged.

Do you have any suggestions on how to accomplish this?

With much gratitude,
Paden

@padenallen15
Copy link
Author

Update

I figured out how to do this. For anyone else wondering, extract the solution package. Go inside the 'Controls' folder and open the 'bundle' JavaScript file.

Search for 'filter=' and you'll find the specific line of code in the function 'MultiSelectPCFControl.prototype.notifySearch' that executes the filtering API call.

The default code is:
filter=contains(" + this.props.filterField + ", '" + newValue + "')&$top=

I updated this to:
filter=contains(" + this.props.filterField + ", '" + newValue + "') and cr7dd_status eq 600500000&$orderby=" + this.props.displayFieldLabel + " asc&$top=

The new code adds my particular filter to only show active status records, and I also added in logic to sort the options by the displayFieldLabel in ascending order.

Once you make the changes, zip all the files together again, and import the new solution in. Note I had to delete the previous solution entirely and add in the new one for my changes to take effect. All works!

@markcunninghamuk
Copy link
Owner

Yes this makes sense. I will be taking a look at thisnas someone has asked for a similar requirement. I will take a look. I'm glad you found a quick fix for now.

@wikky
Copy link

wikky commented Aug 9, 2024

I have a similar requirement. I need to pre-filter based on Business Unit which is a lookup on a custom Product table. How can I accomplish this? I've tried putting the 'businessunitid' schema in the filterField in the component config, but this doesn't seem to work. Any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants