client script doesn't work with passing sys ids

service buzz
Tera Contributor

Hi Team,

 

I have  written a client script on change to make the field invisible for some of the companies .

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
   alert('enter change');
    if(company == 'fa652899db674410e2604f7405961985' ||'62652899db674410e2604f740596193c'||'02b56cc91beaf098bbc299b59b4bcb98'||'6a65e499db674410e2604f74059619ef'||'d48428c8db730594dd7efad3f3961917'||'58472644dbd1f414e57455fbd39619d4')
{
if(det_con == 'yes')

    {
        alert('enter if');
        g_form.setMandatory('loc_it',false);

     g_form.setDisplay('loc_it',false);
     
    }

}
   
   

   //Type appropriate comment here, and begin script below
   
}
 
this is not working any thing wrong with syntax because it always high light the if line where company sys ids are provided
8 REPLIES 8

I realized that and added in the below script

service buzz
Tera Contributor

det type is yes/no 

Community Alums
Not applicable

Hi @service buzz ,

You mean True and False correct ?

So in that condition you write your client script like 

if (det == true) {

  // do something

}

 

Please mark my answer correct and helpful if this works for you
 
Thanks and Regards 
Sarthak

Birla_Krushna
Tera Contributor

Hi @service buzz 

 

You need to modify your code as per below code. Can you try below code,

 

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
alert('enter change');
// Assuming company, det_con, and g_form are defined elsewhere in your script
var company = g_form.getValue('company');   //Use backend value of that field 
var det_con = g_form.getValue('det_con');  ////Use backend value of that field 

if (company == 'fa652899db674410e2604f7405961985' ||
company == '62652899db674410e2604f740596193c' ||
company == '02b56cc91beaf098bbc299b59b4bcb98' ||
company == '6a65e499db674410e2604f74059619ef' ||
company == 'd48428c8db730594dd7efad3f3961917' ||
company == '58472644dbd1f414e57455fbd39619d4') {
 
if (det_con == 'yes') {
alert('enter if');
g_form.setMandatory('loc_it', false);
g_form.setDisplay('loc_it', false);
}
}
//Type appropriate comment here, and begin script below
}
 

This will definitely helps you to resolved your issue. Let me know in case you need to understand the flow or you can DM on LinkedIn.

 

If this solution resolves your query, kindly mark it as the accepted solution and give it a thumbs up.

 

Best Regards,
Krushna Birla