How to hide a variable based on country

sriram7
Tera Contributor

Hi,

 

How to hide a variable based on country

 

EX: Varaible(Buyer Group) needs to hide when Requested For country is France & Ireland

7 REPLIES 7

Danish Bhairag2
Tera Sage
Tera Sage

Hi @sriram7 ,

 

You can create an load/onchange client script for above requirement.Providing u an on load script example if u want u can use onChange as well based upon if manually requested for is selected. Just change the type of the script rest code will remain same

 

function onLoad() {

    var requestedFor = g_form.getReference('requested_for', setCountryAndHideField);

}

 

function setCountryAndHideField(requestedFor) {

    if (requestedFor && requestedFor.country) {

        var requestedForCountry = requestedFor.country.getDisplayValue(); // Get the display value of the country field of the requested user

 

        

 

        // Check if the Requested For country is France or Ireland, then hide the Buyer Group field

        if (requestedForCountry === 'France' || requestedForCountry === 'Ireland') {

            g_form.setDisplay('buyer_group',false);

   

    }

    }

}

 

Thanks,

Danish

 

HI @Danish Bhairag2 

 

as suggested I have written onload client script, However it is not working

 

Below is the code

function onLoad() {
//Type appropriate comment here, and begin script below
var requestedFor = g_form.getReference('request_for', HideField);
}
function HideField(requestedFor) {
if (requestedFor && requestedFor.company) {
var requestedForCompany = requestedFor.company.getDisplayValue(); // Get the display value of the country field of the requested user
if (requestedForCompany == 'Cubis Industries UK, Ireland & France') {
g_form.setDisplay('buyer_groups', false);
}
}
}

 

sriram7_0-1700634936518.png

Do I need to modify any code?

Hi @sriram7 ,

 

Can u put an alert on requestedForCompany variable n tell me wht u receiving?

 

Thanks,

Danish

 

Hi @Danish Bhairag2 

 

Not received any alert