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

Hi @sriram7 ,

 

Can u try this code please. Also can u let me know whichever requester u r selecting what is the company for that requestor . A snip will do.

function onLoad() {
//Type appropriate comment here, and begin script below
var requestedFor = g_form.getReference('request_for');

var requestedForCompany = requestedFor.company.getDisplayValue(); // Get the display value of the country field of the requested user
alert(requestedForCompany);
if (requestedForCompany == 'Cubis Industries UK, Ireland & France') {
g_form.setDisplay('buyer_groups', false);
}
}

 

Thanks,

Danish

 

 

Samaksh Wani
Giga Sage
Giga Sage

Hello @sriram7 

 

You need to write a Client Script for the same :-

 

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

var country = g_form.getValue('country_field_name');

if(country=='sysid_of_france'|| country == 'sysid_of_ireland'){
g_form.setDisplay('buyer_group_field_name',false);
}

 

Plz mark my solution as Accept, If you find it helpful.

 

Regards,

Samaksh

Amit Gujarathi
Giga Sage
Giga Sage

Hi @sriram7 ,
I trust you are doing great.
Please find the code for the same as given. below

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

    // Define the countries that should trigger hiding the variable
    var countriesToHide = ['France', 'Ireland'];

    // Check if the selected country is in the list
    if (countriesToHide.includes(newValue)) {
        // Hide the Buyer Group variable
        g_form.setDisplay('buyer_group', false); // Replace 'buyer_group' with the actual variable name
    } else {
        // Show the Buyer Group variable
        g_form.setDisplay('buyer_group', true); // Replace 'buyer_group' with the actual variable name
    }
}

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi