Select Options where "If" condition is used to create the data list

Hi,

I have the following server action.

image

Here I get the Country View ID of the employee.

If the employee county view ID = 0 then I run a database query to return all countries.

image

I then add a server connect.

image

Now I add the custom select.

image

I then click on the data source in the select.

image

But, this is where I am stumped. I select the Repeat as the data source.
image

Then if I click on the Text Filed
image

You can see the available data is not there?

image

What am I doing wrong?

Any help would be grateful.

Ray.

I think this is the same issue as cropped up here, and probably in one or two other threads too. The issue is:

but I think it was suggested somewhere that a solution might be found. As it is, I think you will have to add the code manually.

Have you tried manually adding the field names to the select to see if that works?

@TomD Thanks for the info.

@Hyperbytes , I tried like this, but stil nothing.

So I’m still at a loss.

I can confirm that the qurey is returning the data.

Ray.

I am having a bit of a problem following your logic (maybe the problem, is the logic?)

You query a database table and return all/ a selection records

You then repeat through the recordset

with an IF you find a record where county view ID = 0

You then query a table and return a list of counties

but as this is in a repeat, if more than one record has country view = 0 this is repeated, effectively until the loop ends

What are you trying to output and what do you expect returned? Do you really want the second query to be executed multiple times if multiple records return intCountryView == 0

@Hyperbytes

OK So this what i’m doing.

I have an employee table which has an intCountryView column flag.

0 = see all counties.
1 = Ireland only
2 = UK only

There is a county table which lists all the counties by county ID, county name and a intCountryView column.

So, the first thing I do is get the intCountryView from the logged in employee.
image
In my case, I can see all counties, so my intCountryView ID = 0

Now (***I could be doing this all completely wrong!***), I run a Repeat so that I can use the returned value from the employees table i.e. 0.
image
image

Now that I have access to the returned value via the repeat, I preform a “IF” statement.
image

If the statement is true, I return all values from the county table. This would have been used to populate the Custom Select.

The next step after would be to preform another “IF” statement. So of the returned value = 1 (Ireland only), then I would have preformed a query to return all the counties linked to Ireland.

If this helps clear it up, great, if not, I am clearly wasting everyone’s time with my BullSh*t logic of how I expected it to work. Hehe :slight_smile:

Thanks,
Ray

This sort of thing is never a waste of time, it has a learning outcome for everyone, that’s what this forum is all about
Is this to be displayed in a single form type layout, multi form or table?

@Hyperbytes Well, I have been pulling my hair out(whats left of it) for the last day trying to work it out.

So, the results would then be used in a Select List on a multi form

Thanks
Ray.

Yes, I think there is a much simpler way to do this with a single query, give me a few minutes to model it

@Hyperbytes Perfect thanks.

If you need any more info, let me know.

Ray.

Are you tied to using numbers, it would actually be easier with letters i.e. I = Ireland, U = UK then you could use the wildcard “%” to see all

The its just a simple query select * where intCountryView = {{parameter}}

@Hyperbytes HI, unfortunately the existing customers database is set to using the three deeply in their existing CRM, so, I have been forced to work with them.

Ray.

No problem, i can work with that

OK, so if i follow you correctly you have a parameter you get via get_country_view_id which returns 0,1 or 2

You then need to use that parameter to return a list of counties within the selected country which are designated 1 or 2 to signify the country

In this example I will use a get parameter but this could just as easily by a var from a set var in the server action

So basically we start with filtering the tblCounty table with the parameter

We then set the filter to be ignored if zero i.e. {{$_GET.intcountryid != 0}}

So the query resolves to
Choose your fields for you select

Then set condition

2 Likes

@Hyperbytes OK, let me have a go at that! But I didn’t know you could set a condition on the query like that, and that will come in very handy going forward! So for that alone “I thank you”.

I will get back to you on the suggested steps shortly.

Ray

1 Like

@Hyperbytes Perfect! Exactly what I wanted and most simplest approach.

image
image

UK Only

Ireland Only
image

All
image

Can’t thank you enough. I can finally move this project along.

Thank you Brian.

Ray.

2 Likes

My pleasure to help

2 Likes