The CreatorCon Call for Content is officially open! Get started here.

Filtering Columns on a Custom Table

Joe Taylor
Giga Guru

I have a custom table with 3 columns.

I'm trying to use a reference variable in my form.

I'd like to filter Column2 pulldown in my form based the selection from Column 1.

I'd like to filter Column3 pulldown in my form based the selection from Column 2.

Here's a sample.

What's the best way to handle this?

 

Column 1    Column 2    Column3
 
10 - A         1010 - AA    101010 - AAA
20 - B         1020 - AB    101020 - AAB
30 - C         1030 - AC    101030 - AAC
etc.               2010 - BA    102010 - ABA
.                   2020 - BB    102020 - ABB
.                   2030 - BC    102030 - ABC
.                   3010 - CA    103010 - ACA
.                   3020 - CB    103020 - ACB
.                   3030 - CC    103030 - ACC
                     etc.
                     . .
                     . .

 

 

7 REPLIES 7

Hari Prasath
Tera Guru

Hi @Joe Taylor  ,

 

May be you can set the column 1 as dependency value for column 2 & 3. Please let me know if you've any questions.

 

Please mark the answer helpful, if it helped you accordingly.

 

Thanks,

Hari

I'm not sure how to implement this.

Do you mean the "Dependent" and "Dependent on field" columns in the database?

If so, I still don't know how to adjust the pulldowns in my form.

Each column has it's own pulldown and refers to one of these columns.

Joe Taylor
Giga Guru

Hari's suggestion isn't detailed enough for me.

 

Does anyone have any further advice for me on this?

aloktomar055
Tera Contributor

you can achieve this functionality using Client Scripts

 

(function() {
// Define function to filter Column 2 based on Column 1
function filterColumn2() {
var column1Value = g_form.getValue('column1'); // Get the value of Column 1
var column2Field = g_form.getControl('column2'); // Get the reference to Column 2 field

// Clear existing options
column2Field.innerHTML = '';

// Populate Column 2 options based on Column 1 selection
// Implement your logic here to fetch options dynamically, e.g., via GlideAjax
// Add options to column2Field using DOM manipulation
}

// Define function to filter Column 3 based on Column 2
function filterColumn3() {
var column2Value = g_form.getValue('column2'); // Get the value of Column 2
var column3Field = g_form.getControl('column3'); // Get the reference to Column 3 field

// Clear existing options
column3Field.innerHTML = '';

// Populate Column 3 options based on Column 2 selection
// Implement your logic here to fetch options dynamically, e.g., via GlideAjax
// Add options to column3Field using DOM manipulation
}

// Register onChange handlers for Column 1 and Column 2
g_form.observe('change', 'column1', filterColumn2);
g_form.observe('change', 'column2', filterColumn3);
})();