Cascade single_select based on 3rd column of parent single_select

AnnaFoot

New member
Hello,
I choose the name of a property - which is defined by the propertyid. This is a cascade single-select field where the propertyid is captured, and the actual address is listed. This works fine. Each property has a type - many properties are of each type, so when the property is chosen, i know the type, but i want to capture the propertyid. I would like the propertytype of the chosen property, which the user doesn't need to know, to filter the next single_select box. The property type value is in the table that holds the properties. It is also in the table that populates the new single_select. I don't know how to let the system know that i want the third column in the propertyid single_select field to be used to filter the new single_select not the first column. Is that possible?

Your current DaDaBIK version​

You are using DaDaBIK version 11.7-Elba enterprise, installed on Jul 11, 2023 (installation code: 1897264ad495ee88d3), the latest version of DaDaBIK is 11.10-Elba released on Jul 13, 2023

You are not running the last release of DaDaBIK, the release you are running might have bugs and security holes, see the official change log for further information. You can upgrade DaDaBIK here.

In case you want to upgrade to a more powerful edition (from Pro to Enterprise/Platinum, from Enterprise to Platinum) please contact us.

System info​

PHP Version: 7.4.13

sqlserver version: 14.00.1000

Web server: Microsoft-IIS/10.0

Client: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0

URL installation: https://www.hctracking.co.uk/hcdd/
 

eugenio

Administrator
Staff member
Hello Anna,
the problem is not clear to me, when you say:

This is a cascade single-select field where the propertyid is captured, and the actual address is listed.

I don't understand the context: if each property has only address, why do you need a cascade solution?

Could you try to explain again what you want to get using a more general example?

Best,
 

AnnaFoot

New member
Sorry Eugenio,

I have a set of properties which appear in a single_select field. The set of properties displayed is based on a previous cascade single_select field called Jobs.

So there are a number of jobs and each job has a number of properties. The property cascade list is determined by the job chosen. That all works well. When you change the chosen Job, the list of properties changes accordingly.

Within the list of properties there are a number of property types - so property A is type 1, property b is type 1, property c is type 2 property d is type 1 etc. The cascade property field has three columns - propertyid - the primary key, addres - displayed on the look up, and then propertytype.
The user doesn't necessarily know the property type, but does the know the address.

I want an additional cascade field that is determined by the propertytype. I know what the property type is, because it is the third field in the property cascade. I just need a way to carry that value over to the new cascade field.

I have tried all sorts of things, but the attempt that got me closest was to set a global variable - $property_type in the config_custom file.
I set it to 3 to start.

I have then written the following function which i call from the calculated field of a test field:

function dadabik_getproptype($params)
{
global $property_type;
$PT = get_record_details('VWDDCurrentAddresses', 'PropertyID',$params['PropertyID']);
$property_type = $PT['PropertyType'];
return($property_type);
}

As i change the property type in the form, i can see that the test field changes, so i know i am changing the value of $property_type.

I have set the where clause for the new cascade field - Work Item - to be:
JobPropertyTypeID = dadabik_var property_type dadabik_var

But this doesn't make the list change, it always shows the list where $property_type = 3, the default value i set initially. The list remains the same for both insert and edit

However, if i take out the where clause and instead cascade the parent field as the test field i'm updating, and link that field to the filter field on the new cascade box, it changes the list. But only in edit, not in insert, and only after i have saved the record. So on edit, i can change the address, watch the test field value change, save the record, and then the list has changed. I don't think this is a solution.

Is there a way i can use a value that has been entered on the form through a calculated field to filter this cascade field before it is saved, or can you help me with understanding how to reset a global variable in a better way. It seems that that should work, but maybe i just don't understand the syntax. Or perhaps i need a custom variable - maybe a global variable is set when the page is created, whereas a custom variable can change.

I feel like i ought to be able to call the function above from the property single_select, but i just can't see whether it is changing the $property_type. I also haven't been able to make anything work in the JS event functions - i tried to move the function into Custom_functions_js, but it didn't seem to do anything....

I hope this makes it a little clearer what i am trying to do.

Thank you,
 

eugenio

Administrator
Staff member
Hello Anna,
the cascade feature can only be properly triggered by another select_single field in the same form.
Maybe there is a workaround but at the moment I can't see it, sorry.

Best,
 

AnnaFoot

New member
Thanks for thinking about it Eugenio, at least there isn't an obvious answer i haven't thought of - i think i can make it work by adding in an extra select_single field, i was just hoping not to.

Anna
 
Top