Variable attributes changes based on Choice field

Nagashree5
Tera Contributor

Hi All,

 

I have a field called choose ERP which has dropdowns as SAP and GEOS.

There is another field called Entity Name which refers to a custom table. The custom table consists these columns that is Business, SAP and GEOS. 

The requirement is if the user selects SAP in ERP field, the Entity Name field should show only the Business which have SAP values(The condition will be SAP is not empty for the Business)- (this is working through Reference qualifier). I have to show now only the column sap as well. GEOS column should not be visible in the dropdown.

And if the user selects GEOS in ERP field, the Entity Name field should show only the Business which have GEOS values(The condition will be GEOS is not empty for the Business). (this is working through Reference qualifier). I have to show now only the column GEOS as well. SAP column should not be visible in the dropdown.

 

Currently, I'm showing Business, SAP and GEOS. columns in the dropdown of the Entity field. But the ask is to show only SAP column when SAP is selected and show only GEOS column when GEOS is selected.

 

Can anyone guide me on this.

1 REPLY 1

Amit Gujarathi
Giga Sage
Giga Sage

HI @Nagashree5 ,
I trust you are doing great.
Here's a sample script to give you an idea of how this can be implemented:

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading || newValue === '') {
        return;
    }

    var fieldName = 'entity_name'; // Replace with your actual field name
    var refQual = '';
    
    if (newValue == 'SAP') {
        // Show only SAP column
        refQual = 'sapISNOTEMPTY^ORDERBYsap';
    } else if (newValue == 'GEOS') {
        // Show only GEOS column
        refQual = 'geosISNOTEMPTY^ORDERBYgeos';
    }

    // Update the reference qualifier of the Entity Name field
    g_form.clearOptions(fieldName);
    g_form.addOption(fieldName, '', '');
    g_form.addDynamicChoices(fieldName, refQual);
}


Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi