Cascading Look-up

Hi, I've been testing Plumsail Forms and had been trying to work on doing cascading look-ups. I just can't seem to make it work. I'm totally new to Plumsail and close to giving up.

I am to do a look-up where if you select 'Region', countries under that region will populate my 'Country Office' field.

I setup 'Country Office' as

image

The script I used;

fd.spRendered(function() {
fd.field('Country Office').ready().then(function() {
function filterLookup(v){
// getting the selected Category (0 if nothing is selected).
var categoryId = 0;
if (v) {
categoryId = isNaN(v) ? v.LookupId : v;
}

        if (categoryId) {
            // setting filtration
            fd.field('Country Office').filter = 'Region eq' + categoryId;
        } else {
            // resetting the filtration
            fd.field('Country Office').filter = null;
        }

        fd.field('Country Office').widget.dataSource.read();
    }

    //filter Country Office when form opens
    fd.field('Region').ready().then(function(field) {
        filterLookup(field.value);
    });


    //filter Country Office when Region changes
    fd.field('Region').$on('change', function(value){
        filterLookup(value);
        fd.field('Country Office').value = null;
    });
});

});

What am I doing wrong? Total newbie here

Dear @Jamail_Serio,

Please try to place the code fd.spRendered(...) in the JavaScript Editor, not in the Style property.

Hi Alex,

I obvisouly have the same kind of issues and I am probably as newbie as @Jamail_Serio.
Where do you find the JavaScript Editor? Is it somewhere in the Plumsail form app?
Thanks

Dear @LoviseH,

Yes, you can find it in the Plumsail app:

thanks Alex
need to change my glasses :nerd_face: