Filter Drop down

Hi all,

I wonder if someone can help me me with this problem:

I am trying to allocate a Market Stall to a trader.

I have a drop down list with available stalls for a Market (Select Rag Market - show Rag Stalls, Select Open Market show Open stalls etc) - Works fine.

Now come the rules to spoil everything :slight_smile:

You can not allocate a stall unless it’s ‘Status’ is active

I have a subset which handles this -

Which is used on the limit to subset

The challenge now is to stop the user adding the same allocation twice (can’t allocate the same stall on the same market on the same day)

What I need is to be able to see if the date chosen has already been allocated.

Is there a way in the subset that I could do this? - 'And the date stored NOT EQUAL to the date trying to be added (1)

Cheers - Paul

Is there anyone that can help me with this please?
I am thinking this is probably a ‘Code Studio’ solution.


A couple of Code Studio options I can think of.

The easiest is a custom Validator, where you take the values chosen in the form, do a record lookup, and return an error if the selected date and market stall already exists. This will prevent form submission, but is not the best user experience as you have to try the combo before knowing if it is invalid.

The better, but more complex option is a Callback, which can change the search criteria used to fetch the list of available market stalls. This means you actually hide the incompatible options from the list.
With this option you could fetch a list of all market stall IDs for the selected date, and then add a filter to the search params to exclude those from the results.

Here is a basic Callback code example which adds an extra filter, in this case so that it only returns a record with ID 1623. Obviously your logic would need to be different, but the basic principle is the same of adding the extra filter criteria.

		// Get the template data
		var template_data = fragment_presenter.get_template_data();

		// Add an extra search filter
			'field_path': ':id',
			'value': 1623

		// Set the updated template data
		fragment_presenter.set_template_data('levels', template_data?.levels);

Thanks - I’ll take a look at this and see how much trouble I can get into. I’ve not used ‘Code Studio’ as yet should be interesting :smiley: